I tried to follow Simo Ahava‘s tutorial on how to report a user’s engaged time on a page, but I kept getting lost in his instructions. Simo is a developer, so he really understands how to create the javascript in order to report engagement time. I, on the other hand, am not well-versed in javascript where I can create something from scratch. So that’s what lead me to write this.
Resources:
In this post, for my own sanity, I’m going to try to create a how to that I’ll be able to follow later on. This is an extremely useful metric to apply to Google Analytics account and I would like to easily set this up for future clients without all the headache from my first go-round.
I even signed up for Chris Mercer’s Measurement Marketing courses and tried to follow his video tutorial and I was still lost because Google Tag Manager was different in 2016 when the video was recorded.
We’re going to go a little back-and-forth between Google Analytics and Google Tag Manager, so keep them open in two tabs.
1. In Google Analytics, go to Admin > go to Custom Definitions: Custom Metrics > click on New Custom Metric (if you don’t see the big red button, then check to make sure you have the appropriate permissions).
Name this new custom metric ‘Total Engaged Time‘ and set the formatting type to ‘Time‘ and make sure that the Active box is checked.
Go ahead and save at you’ll see that you have created the new custom metric. Take note of the index number as we’ll use that in a later step.
2. In Google Tag Manager, Create Custom Event Trigger ‘gtm.dom’
3. Create Custom Event Trigger ‘nonIdle’
4. Create Data Layer Variable ‘nonIdeleTimeElapsed’
5. Create Data Layer Variable ‘Interactive Engagement in Secs’
For this step, you’re going to want to head over to Simo’s website and copy the script he wrote in Step #4. Create a new data layer variable with custom javascript, then paste in the code.
6. Create a New Tag in Google Tag Manager
For this step, you’re going to want to head over to Simo’s website and copy the script he wrote in #1. Create a new tag in your own account for custom HTML, then paste in the code. For the trigger, select the custom event you created in step #2 ‘gtm.dom’ then save.
7. Create a Second New Tag
You’ll want to select Google Analytics: Universal Analytics for the tag type. For this one it will be an event.
Fill these out in the event parameters:
-
- Category: Engaged Time
- Action: {{Page URL}}
- Label: {{Interactive Engagement in Secs}}
- Non-Interaction Hit: True
Add your Google Analytics settings and check the box to ‘enable overriding settings in this tag’ which will give you more options.
Fill out these settings under More Settings:
- Fields to Set – Field Name: transport
- Fields to Set – Value: beacon
- Custom Metrics – Index: 1
- Custom Metrics – Metric Value: {{Interactive Engagement in Secs}}
The Index number refers to the custom metric that we created in step #1 above. Since this was my first custom metric, Google Analytics created the index of 1. This number might be different for you, so be sure to refer back to your Google Analytics account.
For the trigger, you’ll want to apply the custom event we created in step #3, then save. Go ahead and publish your container!
8. In Google Analytics, Add Calculated Metric
Go to Admin > View: Calculated Metrics > + New Calculated Metric
Next, you’ll want to set the metric like this:
- Name: Average Engagement
- Formatting Type: Time
- Formula: {{Total Engaged Time}} / {{Pageviews}}
9. Create Google Analytics Custom Report
Create a custom report titled ‘Content Engagement’ with the following:
Metrics:
- Pageviews
- Total Engaged Time
- Average Engagement
- Avg. Time on Page
Dimensions:
- Page
- Source/Medium
That’s it! You have completed this simplistic guide on how to report engagement time in Google Analytics with Google Tag Manager. If you would like to learn more about the reasoning behind each step, make sure to head over to Simo Ahava’s website in the resources at the top of this post. He explains each step beautifully while answering the why.
Again, this guide is to help me have a quick step-by-step to get the setup complete in a quick, simple manner. This helps me and I hope it helps you.
Cheers,
Katie