![]() ![]() Let’s look at a data layer that comes from an ecommerce /order-received page. With a flat data layer like this, you will just have a key and a value. The previous example is a pretty flat data layer. However, not all data layers look like this. ![]() It’s as easy as that, you just need to know the right key, and then input that in your data layer variable to pull data out. If you would like to use this variable later in a trigger or a tag, be sure to fire it on the right event so that your data layer variable gets filled. ![]() This value will stay filled unless it’s overwritten by the later events. If you click on the blog post view event, you’ll see that the author variable is now filled with a value. If you look at any event prior to the blog post view event, the author data layer variable will be undefined. Remember, it is the event of blog post view that actually pushes the author data into the data layer. In this case, if you looked at the Page View event, you’d see that your author variable is still undefined. These events are like little checkpoints that you have on the page. It’s important to understand that variables are resolved based on these events you see in the left hand column (Page View, blog post view, DOM ready, Window Loaded). At first, you’ll notice nothing is there. Go back to Tag Manager and refresh in preview mode, and also reload your page. Unless you have a very specific reason for it, don’t worry about any of the other settings for now. Once you have entered “author” in the Data Layer Variable Name field, you can hit save. (By the way, the word Data Layer Variable “Name” can be a little confusing here, since Data Layer Variable “Key” is really what this field is looking for.)Īgain, if we take a look back at the console, you can see the key and value here: In the Data Layer Variable Name field, you’d enter “author,” because this is the key that corresponds with the value you are trying to pull. In the example below, we called it “dlv – author.” Select Variables > New > Data Layer Variable and give it an appropriate name. Let’s head over to Tag Manager and create a data layer variable. ![]() Creating the Data Layer Variable in Tag Manager To create a data layer variable that pulls the author value, we need to identify the value using the correct key. In the screenshot above, you can see the value of author is admin. Let’s say we want to create a data layer variable to hold the author value. Now, if you want to pull out a value from the data layer and make it available to your tags or your triggers, you would need to utilize a data layer variable in Tag Manager. In the example below, the first key:value pair in object #2 has a key of event, and a value of blog post view. Understanding Data Layer ObjectsĮach object is made up of key and value pairs. Simply type “dataLayer” into the console, and voila, there’s your data layer.Ĭlick the down arrow next to the data layer array, and you can see the different objects inside. You can see it here: Method #3: Using Chrome Developer Tools > ConsoleĪ third way to find your data layer information is using the console tab in developer tools. This will highlight any instances of “dataLayer” in yellow, making them easy to find. Select the elements tab, and type in “dataLayer” in the search bar at the bottom of the window. Method #2: Using Chrome Developer Tools > Elementsĭepending on how it was pushed, you should also be able to see the data layer information using Chrome Developer Tools under the Elements tab. Here you will see the information that was pushed into the data layer. Open preview and debug mode in Tag Manager and select the Data Layer Tab. GET THE FREE COURSE 3 Ways to See Data Stored in the Data Layer Method #1: The Data Layer Tab in GTM Preview Mode ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |