Skip to content

Instantly share code, notes, and snippets.

@robflaherty
Created October 10, 2014 20:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robflaherty/c3c1d09b6388067e822c to your computer and use it in GitHub Desktop.
Save robflaherty/c3c1d09b6388067e822c to your computer and use it in GitHub Desktop.
if (document.documentElement.clientWidth < 600) {
jQuery.scrollDepth();
}
@tannerchung
Copy link

I think I'm going to do

<script>
jQuery(function() {

    if ( $( window ).height() != $( document ).height() ) {
        jQuery.scrollDepth();
    }

});
</script>

If that makes sense.

However I won't be able to track user behavior for those pages in which the document is smaller or the same size as the window.

If I use your Riveted and ScrollDepth scripts together, do the events all correlate? For example if I look at one page and its view, I'll see which percentage events were triggered as well as the time they spent on the page? So what I'm hoping is that if there is no ScrollDepth data for that page because it's too small the I will at least be able to see how much time they spent on that page.

Also both scrollDepth and Riveted have this feature:

"The first interaction also triggers a User Timing Event, which allows you to measure the number of milliseconds from the pageload to the user's first action."

Does that mean it will be triggered twice if I use Riveted and ScrollDepth?

@robflaherty
Copy link
Author

hey,
that would work. you could also use the plugin's minHeight option to do the same thing:

jQuery.scrollDepth({
  minHeight: $( window ).height()
});

Riveted and Scroll Depth don't know about each other. Events are entirely separate. So yes, those user timing events will be sent twice.

Running both Riveted and Scroll Depth at the same time could generate a lot of events so I'd recommend setting the Riveted reporting interval option to 10 seconds, and maybe turning off some of the scroll depth events like user timing or pixel depth.

@tannerchung
Copy link

I don't see an option on your site for user timing or pixel depth on the riveted site.. using the syntax I see on the scroll depth site however. Does this look right? Are there other options that are unlisted on riveted? And thanks for the scrollDepth snippet .. makes a lot more sense.

<script>
    riveted.init({
        reportInterval: 10,
        userTiming: false,
        pixelDepth: false
    });
</script>

@robflaherty
Copy link
Author

Pixel Depth and User Timing options are only for the scroll depth plugin. Sorry for the confusion. For Riveted, the only option you need is reportInterval.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment