Hello there and welcome back to another video of measureschool.com teaching you the data-driven
way of digital marketing.
My name is Julian, and I'm back with another quick tip video, this time about empty values
within Google Tag Manager.
Now to set you up, I have a little example here.
We are here on a page where I want to fire an outbound link event that ties into Google
Analytics.
So we can see whether somebody leaves our page and through which links they actually
leave.
And when I click on this first link up here, I'm getting redirected to measureschool.
Now, let's do this all with the Command key press.
So we see the event inside of our preview and debug mode.
Here is our GTM link click, and we see our event outbound link click has fired.
Now the event values that we actually send with it is the category outbound link that
tracks event, action, and label.
So here we have the label, the action of the actual page where we send the user to.
Now once we go over to the variables, we actually pull this from the click variable right here.
I have another example here.
And this happens quite often.
Once you click on, for example, a button that not acts like a link per se, a new window
opens, we can go back here, and we can look into our event that fires which was the ninth
event here, and we see that our click URL is empty.
Now, this is unfortunate because when our event outbound link click now fires, it doesn't
have the actual value to fill into our action right here.
So what happens, let's look into our Google Tag assistant.
We go into our event outbound link click, and we see our action is undefined.
And this is also what is then transferred over to Google Analytics, which is unfortunate
because it skews our data to this undefined value.
But it happens quite often, especially when the link is not standard HTML, but is pulling
it from somewhere else.
So right now, I have a JavaScript link actually in the background here.
And that's why it's not picking it up.
Now, what can we do to actually prevent our tag from firing, because we don't want to
have that data in there?
We would need to find a way to prevent our tag from firing when the actual click URL
is empty.
And unfortunately, this is not an empty value, because it is actually a string, just a string
itself is empty.
So if we would change our trigger around, I'm going to go over here to triggers and
outbound link and say, Hey, I don't want to fire this when the click URL, for example,
does not equal empty, then I want to not fire this.
So let's try this out.
But unfortunately, we can't actually save this because we have the filter not really
specified, we don't have anything in here.
So you need to fill something out in order to make the filter actually work.
So what can we actually do?
Well, there is a little technique Regex called and we can choose the does not match the regex.
So we would find out if the strings actually empty.
And we can do this by using the caret and the dollar sign, which would mean that our
string would need to start with a character after this and stop with the character before
this, which is the empty character right here.
So in the end, it will hopefully work and match our regex here.
So it should not match, our click URL should not match the regex empty string.
If it does, then this whole thing should fail.
Let's try this out.
Let's save this and refresh and refresh this page.
And we click on measureschool again.
We see our GTM click here and our tag didn't fire.
Why did it not fire?
Let's click on it.
And we can also look into our fire and conditions right here.
The event was right, the click URL but it matched up to our condition right here and
that's why it failed.
And if you click on any other link here,
we would need to do that with the Command key press.
We see that our event still works.
Also with the affiliate link, it should still work, yes.
So this is a quick tip on how you can match up empty character strings with the help of
this regex option of the caret and the dollar sign.
So just remember this little term if you ever find yourself as you want to match up an empty
string.
Hey, there it's me again.
Thanks for checking out our quick tip video.
Was that helpful?
Did you understand something not quite?
Then I'd love to hear from you in the comments down below.
But if you liked it then why not give us a thumbs up
and subscribe to our channel
right over there because we bring you new videos just like this one
every week.
Now, my name is Julian,
til next time.
Không có nhận xét nào:
Đăng nhận xét