Histories and exclusions

View Markdown

Use this guide to decide what to exclude and verify what was sent. Choose how to configure exclusions:

Item IDs, Histories, and Exclusions

Tag content items with IDs when possible:

<article class="news-card" data-froomle-id="sample_item_id_1">
  ...
</article>

This gives the SDK stable item identity for features such as recommendation attribution, control-branch tracking, and opt-in in-page exclusions.

Contract note:

  • data-froomle-id is generic item identity. It is not automatically sent as behavioral pageview history.

  • Automatic recommendation impressions and clicks require a card registered by the SDK with current recommendation request attribution. Adding data-froomle-id or copying a request ID into markup does not register the card.

  • Use addHistories(…​) when you intentionally want to send behavioral histories.pageviews.

  • Use in-page exclusions when you only want to prevent already-visible items from being returned in the current recommendation response.

Inject histories (simple IDs):

import { addHistories } from '@froomle/frontend-sdk'

addHistories([
  'sample_item_id_1',
  'sample_item_id_2'
])

addHistories([…​]) generates histories.pageviews. For string IDs, item_type defaults to article.

Inject typed histories when explicit item_type is needed:

import { addHistories } from '@froomle/frontend-sdk'

addHistories([
  { id: 'sample_item_id_1', item_type: 'article' },
  { id: 'sample_item_id_2', item_type: 'video' },
  { id: 'sample_item_id_3', itemType: 'podcast' } // `itemType` alias is supported
], 'article') // fallback item_type for entries without explicit type

Behavior note:

  • addHistories(…​) appends entries to histories.pageviews in outgoing recommendation requests.

  • For string entries, SDK uses defaultItemType (or article when omitted).

  • For object entries, SDK uses item_type or itemType; if missing, it falls back to defaultItemType (or article).

  • setCustomVariable('histories', …​) writes the raw histories field directly only when consent allows histories. Under consent levels 0 and 1, raw custom histories is suppressed; generated/request-local histories.exclude may still be sent.

  • This is separate from context_item_type (used for detail context and detail_pageview), which defaults to article when omitted.

In-page Exclusions for Deduplication

Use exclusions to keep items such as cards already on the page out of a recommendation response. The SDK sends them as histories.exclude, with reconsumable: false. An exclusion applies to that request; it does not record a read or a pageview.

histories.pageviews is separate behavioral input. Consent levels 0 and 1 suppress that history but still allow request-local exclusions. Even when addExclusions(…​) keeps IDs for later requests, the SDK sends those IDs as filters, not as history.

Recommended Production Order

Recommended production order:

Source Use when Notes

Stable data-froomle-id

You control the rendered page markup.

Preferred setup. Add data-froomle-id and, when known, data-froomle-item-type to every non-Froomle item that should be excluded from the recommendation response.

Configured CSS selector / attribute

The CMS or framework already renders stable item IDs, but under another attribute name.

Configure the selector and ID attribute explicitly. This is production-safe when the attribute is stable.

Regex extraction

The only stable ID is embedded in another value, for example an article URL.

Configure idRegex to extract the backend item ID from the selected attribute. Prefer a narrow selector and a tested regex.

Manual request exclusions

Your integration already has the visible item IDs in JavaScript.

Pass exclusions directly on the request. This avoids DOM scanning and is usually the clearest programmatic integration.

React excludeItems

Your React/CMS integration already has the visible item objects in memory.

Prefer this over DOM scanning for React pages. Pass the item array together with getId(…​) and itemType / getItemType(…​); the SDK maps it to request-level exclusions.

Mode-by-mode Summary

Mode Enable with Where excluded IDs come from Tracking implication

DOM/script-tag

data-froomle-auto-exclude="page" and optional selector attributes on the SDK script tag.

Page markup, by default [data-froomle-id].

SDK-owned DOM rendering and tracking continue to work for data-froomle-reco placements.

Declarative DOM feed

data-froomle-reco-feed on the containing section. See Load More and Infinite Scroll.

Filled cards still in that feed, merged with configured exclusions for the current request.

The SDK renders and tracks the recommendation slots.

Programmatic JS

getRecommendations(…​, { exclusions }) or getRecommendations(…​, { autoExclusions }).

Caller-provided IDs, or DOM scan at request time.

If your application renders the finished cards, send recommendation impressions and clicks explicitly.

Framework queued requests

proxyReco(…​) request options or global setAutoExclusions(…​).

Request-level IDs, page markup, or global auto-exclusion config.

Compatible placements batch together; placements with different effective exclusion sets split into separate requests.

React useCreateReco(…​)

Hook option exclusions, excludeItems, autoExclusions, or global setAutoExclusions(…​).

Request-level IDs, caller-provided item arrays through excludeItems, or page markup scanned when the hook request is fulfilled.

Render with FroomleReco reco={reco} for automatic impression and click tracking.

React useRecoList(…​)

Hook option exclusions, excludeItems, autoExclusions, or global setAutoExclusions(…​).

Request-level IDs, caller-provided item arrays through excludeItems, or page markup scanned for the list request.

Render selected entries with FroomleReco entry={entry}, or pass an unmodified recommendation item as FroomleReco reco={item} for automatic tracking.

React useRecoEntry(…​)

Hook option exclusions, excludeItems, autoExclusions, or global setAutoExclusions(…​).

Request-level IDs, caller-provided item arrays through excludeItems, or page markup scanned for the entry request.

Render with FroomleReco entry={entry} for automatic tracking and benchmark attribution.

Behavior Notes

  • Auto-exclusions are disabled by default.

  • Request-level autoExclusions overrides the global config from setAutoExclusions(…​) for that request.

  • Automatic collection is only reliable when the page exposes stable item IDs. Prefer data-froomle-id and data-froomle-item-type.

  • By default, the SDK excludes explicit page items but not the current recommendation placement itself.

  • Exclusions are merged and deduplicated by item_type + id.

  • Queued placements with identical effective exclusion sets can still share one outgoing recommendation request.

  • Queued placements with different effective exclusion sets are split into separate outgoing recommendation requests, because histories.exclude applies to the full backend request.

  • Exclusions are request-local response filters. They may be sent under consent levels 0 and 1; behavioral pageview histories and raw custom histories are still suppressed.

Verify what was sent

After triggering a recommendation load, open the relevant POST /recommendations/requests in the browser’s Network panel. Inspect histories.exclude for the item ID and type you expect to omit. Check histories.pageviews separately if you are testing consent or history.

In window.FroomleFrontendSdkRuntime.diagnostics.autoExclusions:

  • lastCollectedCount describes the most recent selector scan. It does not show every source or prove that a request started.

  • lastSentExclusions shows the exclusions on the most recent dispatched recommendation POST. For each item, check origins for all contributing sources: for example addExclusions, a selector, or dom:feed. Origin labels are diagnostics only; they are not sent in the payload.

When multiple requests are in flight, use the specific Network entry for the request you are checking. If a dispatched request at consent level 2 omits generated exclusions, check whether a raw setCustomVariable('histories', …​) override replaced the generated fields.