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

Track elements visibility #36

Open
eloquentarduino opened this issue Nov 13, 2024 · 0 comments
Open

Track elements visibility #36

eloquentarduino opened this issue Nov 13, 2024 · 0 comments

Comments

@eloquentarduino
Copy link

As it is now, impressions are tracked even when elements are not visible in the viewport ("below the fold"). I think it may be a valid metric to track, since one may want to know how many clicks/hover were performed after the element was actually visible.
I wrote a quick implementation locally which seems to be working fine. The "main" part is the JS code which looks like this:

intersectionObserver(function (entries: IntersectionObserverEntry[]): void {
        entries.forEach((entry: IntersectionObserverEntry): void => {
            const name = entry.target.getAttribute("data-pan");

            if (!name || !entry.isIntersecting || visible.includes(name))
                return;

            visible.push(name);

            queue.push({
                type: "visible",
                name: name,
            });
        })
    })

Is this something that could be integrated?

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

No branches or pull requests

1 participant