Hey there!
I'm Benjamin from Loves Data.
In this video I'm going to show you how you can use the element visibility trigger in
Google Tag Manager.
Using the element visibility trigger allows you to fire a tag, like a Google Analytics
event when a particular element is visible in a user's browser.
For example, if you have a promotion or other important element you want people to view,
like a form on a lead page, then you can track its visibility into Google Analytics with
the help of Google Tag Manager.
So let's look at the element visibility trigger!
Let's get started!
// The element visibility trigger lets you trigger a tag based on the element's ID or
the element's CSS selector.
Let's say I want to fire a tag every time someone scrolls to the bottom of my website
and views my email subscription form...
To begin I'm going to right click and select 'inspect' for the element.
I can see that the form is contained in a div and that the div has a class of 'newsletter
form body', so I can use this to configure the trigger.
Let's head to Google Tag Manager...
I'm going to use event tracking to track the visibility of the form into Google Analytics,
so let's select 'tags' and then add a new tag...
I'm going to name my tag 'email updates visible' and I'm going to select 'universal analytics'
as the tag type.
Now I'm going to select 'event' as the track type and enter the event category, action
and label.
You can use variables to dynamically pass the details of the element that is visible,
but for this example I'm going to keep things simple and hard-code the values for the event.
I'm going to set 'non-interaction hit' to 'true' which means that the event won't impact
the bounce rate for my page.
For example, by setting this to 'true' it means that someone who views a single page
and leaves my website will still be reported as a bounce, even if the event is sent to
Google Analytics.
Then I need to select my Google Analytics Settings variable.
Now it's time to configure the trigger...
I'm going to click the plus sign to add a new trigger...
And I'm going to name the trigger 'Email Updates Visible' and select 'element visibility' as
the trigger type.
Now I can select 'CSS selector' as the 'selection method' and enter the class for the div that
I found for my website.
I'm going to enter 'dot', since it's a CSS class, then 'newsletter form body'.
I only want the trigger to fire the tag once per page, so I'm going to leave the 'fire'
option to 'once per page'.
You can change this to 'every time an element appears on screen', which would mean the tag
will fire every time the element is visible.
I don't suggest using this as you can quickly reach the session hit limit for Google Analytics.
We can then select the percentage of the element that needs to be visible for the trigger to
fire.
I'm going to change this to one hundred percent.
I'm going to leave the other options as they are and save the trigger.
Now let's preview the container...
I'm going to head back to my website and reload the page...
I can now see in the debug console that my tag is firing when I scroll down the page
and one hundred percent of the form is visible in the browser.
That's it!
Now I can publish the container to my website.
// So that's how you can use the element visibility trigger in Google Tag Manager to fire a tag
when an element is visible in the browser.
All you need to do is identify the element on your website that you want to track, decide
what sort of tag you're going to use and then configure the trigger.
If you're going to send events to Google Analytics like I've covered in this example, remember
that you'll want to review how many events and other hits you're sending, since there
is a session hit limit with Google Analytics.
This is why you won't want to trigger the tag every time the element is visible on the
page - just trigger the tag once per page.
Are you using the element visibility trigger in Google Tag Manager?
I'd love to know!
Let me know in the comments below!
And if you found this video helpful, then please like it, so I know to make more videos
like this.
See you next time!
Không có nhận xét nào:
Đăng nhận xét