Fire Launch Rule Upon Scroll Depth And Time Spent

The inimitable Simo Ahava recently posted an article named Fire GTM Tag Upon Scroll Depth And Time Spent, in which he explains both why and how to fire tracking after visitors have either lingered on or scrolled to a certain depth on pages.

With his permission, I’ll show you how to do the same with Launch, by Adobe.

Why?

The idea is to measure how the content on your web site is being consumed, read. A lot of people use metrics like “Time on Site” or “Time on Page” or “Time Spent” or whatever your Solutions calls it to figure this out, or rather to approximate it.

The huge problem with that is that you can’t actually measure whether a visitor is really looking at the page while it is open. For all we know, they could have left the room!

If you’re a media site, or if your site has content that is considered important (banks have a lot of that), then you need to know whether your content people write the right stuff.

And while the approximation helps, there are better ways, some of which both Simo and I have written about.

This time, Simo suggests combining time and scrolling.

If a visitor scrolls a certain way, and if they linger for more than a certain time, do something.

The novelty is to combine those two conditions in a single Rule, to use two different parameters and trigger one action.

You might remember that I did something similar with DTM some time ago (see Delayed Page Load Tracking with DTM), but now we have Launch. And it’s easy-peasy with Launch.

How?

Just like GTM, Launch treats multiple Events in a Rule as “OR”, meaning any of the two Events would trigger the Rule.

Simo gets around that by making sure the triggers each take into account whether the other has already fired or not. We can do the same thing in a bunch of different ways in Launch.

One way would be to do it like in the “delayed page load tracking” article mentioned above, using a “Custom Event” Event and a single Rule. A variation of that could be to use a “Custom Code” Event.

Another way would use three Rules. The first would trigger on time, the second on scroll depth, and both would call the third, actual, Rule, which would have a condition “both have fired”, so to speak.

I don’t particularly like any of those approaches. There would be a lot of Javascript code, hidden away, yes, but it wouldn’t be clear to a casual observer what the Rule/Rules was/were doing.

The proper way of doing this in Launch, you ask?

Well, obviously, we build an Extension!

The Extension will provide a single Event Type, which encapsulates the whole thing, and which has four configurable settings:

  • Threshold of time spent on page,
  • threshold for scroll depth in %,
  • a toggle which can be set to “fire just once per page” or “fire every time this happens”, and
  • a delay time for attaching the scroll listener, in case the page builds dynamically.

In order to complete the Make an Extension mini series, I’ll write about how to test an Extension in the sandbox (there have been changes), how to test it on the integration environment, and how to publish it, when it is done. done

For now, all you need to do is find my Extension in the Catalogue, add it to your Property, then use it in your Rule.

Ah, so simple!

If you want, you can see the sources on github, of course.

Notes

It was great fun writing this little Extension!

The process has changed since I wrote about making an Extension, which means I got to write about the changes. I was also able to write the final article, about publishing your Extensions.

So thank you, Simo, for pushing me to dig deeper into this topic!

The whole thing is possible with DTM, too, but given that we now have an official end of life announcement, I shall ignore DTM completely from now on.

One flaw in my Extension is that it is imho overly specific. I may or may not work on an alternative Extension that provides all sorts of “engagement”-related Events

4 thoughts on “Fire Launch Rule Upon Scroll Depth And Time Spent

      1. Hiya Jan,

        Apologies…these might be stupid questions. I was working with the extension (which is super useful btw!) and just had a few things I needed clarifying…although suspect it’s the way I’m trying to do it.

        So I’m firing an event through Launch and then writing to the console when it fires (as I wanted to check what was coming through). And into the console I’m writing the % of the page viewed based on the following bit of javascript:

        Math.round((window.pageYOffset / document.body.offsetHeight)*100) + “%”

        Basically getting the point at which the rule was triggered and dividing by the length of the page (and converting to %).
        But I’m getting different % numbers to the % I’m setting the rule at. Is it just the way that I’ve calculated it is different?

        The other thing I wanted to clarify was the combination of the two elements (time spent AND scroll depth). If I set both to 5 does that mean this will be triggered if a user spends longer than 5secs at any point greater than 5% down the page? Or just that they’ve been on the page for longer than 5secs and have exceeded 5% at some point?

        Am I right in thinking that to use this with Adobe Analytics the best way is to set up multiple rules which fire at differing intervals (e.g. 20%/40% etc…)???

        Apologies if these are noddy questions…I’m dabbling with scroll depth tracking for the first time.

        Mark

        Like

      2. Hi Mark,

        So for the first question: I use a slightly more complex logic, see https://github.com/janexner/launch-extension-time-spent-and-scroll-depth-event/blob/master/src/lib/events/combinedTimeSpentAndScrollDepth.js

        It’s also possible that the Rule doesn’t fire _exactly_ when you pass, say, 25%, but a little further down. Browsers do funny things with UI events.

        In terms of combination, your second part is correct: set both to 5, and the Event will trigger as soon as 5 seconds on page have passed and scroll is 5% down or more. The wait time is for the page, not the offset.

        You are absolutely right on the third part: multiple Rules with different intervals.

        Cheers,
        Jan

        Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.