Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: content tracking example #29

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

auto200
Copy link
Contributor

@auto200 auto200 commented Feb 12, 2024

Example scenarios in assumption that we have Interactions with popups content enabled in the admin panel:

User lands on a page with content tracking tags in the DOM

if content loads before tracker script fires, content will be tracked

User navigates from one page to the other page with content tracking tags in the DOM

tracker already finished it's initialization thus content will not be tracked

User sees a loader, then content with tracking tags in the DOM appears

there is a high chance that content will load after tracker finished initialization thus dynamic content will not be tracked


Problem with calling trackAllContentImpressions multiple times

There is a dynamic component, like tabs (see login/register form example)

  1. on mounting tab content we call trackAllContentImpressions
  2. tracker marks (internally) those elements as being tracked
  3. we switch tabs back and forth, component gets unmounted and remounted, content tracking listeners get lost but in tracker internal state those elements are still marked as already tracked so new listeners are not being attached

current workaround

jstc exposes clearTrackedContentImpressions (although it is marked as internal and not documented) so we can use it to reset tracker's internal state before calling trackAllContentImpressions

other possible options (changes in jstc required)

  • for content interaction we could not attach listeners to specific elements but to the body and check if clicked element was inside or has content tracking related tags. Similar how it's done with link tracking, This way we would not care if DOM changes
  • for content impression only thing that comes to my mind is usage of MutationObserver and scanning DOM for newly added elements with content tracking related tags

@auto200 auto200 force-pushed the feat/content-tracking-example branch from a548ab9 to 61507dc Compare February 13, 2024 09:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant