Skip to content
This repository has been archived by the owner on Aug 21, 2024. It is now read-only.

Is this the way to implement stepped scroll tracking? #252

Open
Jogai opened this issue Dec 11, 2019 · 0 comments
Open

Is this the way to implement stepped scroll tracking? #252

Jogai opened this issue Dec 11, 2019 · 0 comments

Comments

@Jogai
Copy link

Jogai commented Dec 11, 2019

What I want is to send only one event per range. So if I divide my page in quarters I send an event for 25, 50, 75 and 100%.

A user that scrolls to 33%, then to 44%, then back to 36% would once send an event with 25 as eventLabel.

Sorry I was rubber ducking, I think this should work:

    ga('require', 'maxScrollTracker', {
            increaseThreshold: 25,
            hitFilter: function(model) {
                var scrollPercentage = model.get('eventLabel');
                // round to 25's
                model.set('eventLabel', 25 * Math.round(scrollPercentage / 25), true);
            }
        });
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant