So the most confusing part, if you are, let's say somewhere between the beginner and the
intermediate user in Google tag manager, is that when you're dealing with Google it with
the data layer, there are actually two data layers, not one that you're thinking of, but
actually two. And I believe that this is quite confusing.
Hey there, measuregeeks, Julian here back with another video. Today, we have Julius
from Analytics Mania on the channel. Since 2016, Julius has been sharing his knowledge
and his experiments and his learnings related to web analytics, mainly Google analytics
and Google tag manager. If you haven't already checked out his blog, it is a must read. Now
I talked to Julius for our upcoming coming event, Measure Summit, where he conducts a
session about the GTM data layer. Today, we're going to hear a little part out of the session
where he specifically talks about the fact that are actually two data layer. Can you
believe it? You can catch the whole session and many others at Measure Summit 2020. So
just head over to measuresummit.com and sign up for your free ticket today. All right,
we've got lots to cover. So let's dive into the Measure Summit session with Julius from
Analytics Mania. So the most confusing part, if you are, let's
say somewhere between the beginner and the intermediate user in Google tag manager, is
that when you're dealing with the data layer, there are actually two data layers. Not one
that you are thinking of, but actually two. And I believe that this is quite confusing.
So brace yourself. And if this still is confusing, don't worry. I have been there and many other
people have also been there, but let's take a look. So when you are dealing with the data
layer in the preview and debug mode, by the way, the preview and debug Mount on the left
side, it displays all the data layer pushes that were made on a page. So every item is
the data layer push. So this data layer push is, so this data layer is what is happening
in Google tag manager. Now some of you might also know that you can
check the data layer in the browser console. So if you go to the developer tools of let's
say Chrome browser and enter data layer in the console, you will also see some items.
Now, visually, they look very different, but like, it looks like from the content wise
perspective, uh, they look kind of the same because we have right here, we have six data
letter pushes. So this is the first data layer push. This is the sixth one. And in this case
we see also six items. This one starts with zero and then on the fifth, the very last,
last particular push was GTM.load, which is also known as window loaded. So it might look
that they are the same thing. They are the same things, but they are actually different
things. Now, let me clearly quickly explain that. When you do a data layer push or when
a developer does a data layer push that data layer push adds a new information and new
data into the data layer. And when I talk about data layer, I mean this
data layer because this data is on your website. This is what is happening on your site. This
is your websites or web applications data layer. Now this is the data layer of Google
tag manager. And what happens is that when a data layer push occurs and it pushes data
to the website's data layer that you can access with, let's say with the console of your browser,
it then updates Google tag managers' internal data model. So in other words, that when data
layer push occurs, the data is pushed right here. And then based on that data layer push,
the information is updated in Google tag manager internal data model. Now, while usually they
look the same, there might be some situations when the content of your website's data layer
and your Google tag managers data layer is different.
And one of the things that you should keep in mind is that, and actually, what is confusing
is that data layer in Google tag manager. I mean, the data model is quite often called
data layer as well. So you have kind of like two data layers, even though there is one
data layer on your website and it updates the internal data model of Google tag manager.
And then later when you configure your GTM configuration, then that data is sent somewhere,
let's say to Google analytics. So when you are using data layer variables, data layer,
let's see custom event triggers. They are reading data from the internal data model
in Google tag manager, not in the data layer. So they access the data, not here, but in
the preview and debug mode right here. Uh, so to sum up, this is the data layer of your
website. And in this case, we have like eight data
layer pushes. So each data layer pushes an object. If we clicked on this, they would,
that, that data, little push would be expanded and we could see what kind of content was
pushed. And also at the end, we see something weird, something mysterious, which is called
push. And this is a function. And the data model is right here. You can see the most
recent data model values in the data layer tab of Google tag manager. And this is actually
what makes it confusing because it says data layer, even though in reality, I mean, technically
speaking, this should be the data model. But, um, I understand the design and the idea behind
this design because it would be even more confusing for developers for beginners to
explain that, Hey, this is kind of like a data layer push, but you're working with a
data model and like a difference talking about, uh, let's say the differences is that the
data layer in, uh, in, on your website that you can access with the console is an array.
So you can access, let's say the third data layer push, and you can get some data from,
from that data layer push. You can access the eighth data layer push. Now, when we're
talking about data model, you can access with data layer variables only the most recent
value of that particular key. So in this case, in the, if the value of the page posts type
on window loaded was a bit different. And then on gtm.click, it was post, you with data
or verbal can access only the recent value of that, um, of that page post type key right
here. And this is all possible because of this push method right here. When data layer
is created on a website, this is not some simple regular data layer. It's actually a
special, uh, array that contains a modified push method. Because if you have at least
some knowledge in JavaScript, you know, that arrays have various methods that you can work
with. So push, pop slides on shift and so on, and
they can do different things with arrays. Now, a push method in, in the data layer of
Google tag manager is a bit modified. It not only adds an element to, to the array, but
it also then takes that information and transfers, let's say the copy of that information to
Google tag managers, internal data model. And that is why this is very important. If
this push method does not exist, the data layer, even though you can see the information
right here, it will not update your data model in your Google tag manager. And I will quickly
show you, uh, actually soon. What, why does it happen? Hey, this is Julius from Analytics
Mania, and I wanted to invite you to the Measure Summit I will be talking about the data layer,
and I will give you some tips and gotchas that you need to know.
All right, so there you have it. This is a sneak peek from the session with Julius from
Analytics Mania. He went on to other interesting tips about the data layer, which you should
definitely learn about. If you're interested to see the whole session, you can sign up
to Measure Summit at measuresummit.com and get your free tickets for the event. And we
actually have more sessions from Simo Ahava to Krista Seiden to Brian Clifton, many, many
others. So don't miss out. I hope to see you at Measure Summit 2020. And as always, my
name is Julian. Til next time.