Use a data layer to set Analytics variables in Experience Platform tags

Learn how to pull values out of the data layer and use them in Experience Platform tags to populate variables in Adobe Analytics. Using a data layer for Analytics and other Experience Cloud solutions is a best practice.

Review additional information about data layers in the Analytics and Experience Platform tags documentation.

Transcript
Hey everybody, this is Doug, in this video I want to show you how to use a data layer to set page names and site sections or really any variables in Adobe Analytics using Adobe Launch. Now you’ll see here I have a little test page, and there is a reference to launch on here so let’s look at the source. And as I scroll down here still in the head of the page you’ll see that I have a call here to launch, and then there’s just the text down there. And I also want to show you that I have a Data Layer put in here. Now this one is quite extensive, your Data Layer might be less or more than this, you might be using the W3C digital layer standard. You may be using something that is very specific to your company, whatever you wanna use is fine, but we do recommend that you use a Data Layer and that is the best practice for analytics and other experience cloud solutions. So you’ll see here though that I have window.digitalData and I have a page section and a pageInfo section and that’s where my pageName is. And then you’ll also see down here I have a category section which is under the page category and then primaryCategory Company Info Pages right there, so those are the couple of things that I’m going to show you in this video and obviously you could pull any of these data points out of here and out them into your beacon to send into analytics. Now I’m gonna jump back into Launch real quick here to show you that I do have Adobe Analytics set up and if I go into configure just to kind of give you a little bit of background here on what’s set up, I do have the Library Management set up to Manage the library for me, and I have my report suites set up and I have my tracking service set up etc. But that’s really about it, and then I do have a Rule that is there, I didn’t make any changes really, a rule there to send in the beacon and that’s all I’m really doing is sending in the beacon so when I have that page, and I run it, I do have beacon right now, but as you can see here I don’t really have a Page Name or any other variables I just have a really basic beacon going in, with really no data to speak of, anyway we want to show you how to use this Data Layer to send data in so, again we need to be able to pull data from that Data Layer and as a review I want to pull the Page Name and I wanna pull this primaryCategory and put them in there so, that’s the first thing that we have to know, is we have to know how to reference the data in your Data Layer. So it is your responsibility to build the Data Layer and to be able to reference the data that’s going into it. Okay we can’t really help you with that, where to get your pageName, it’s gonna come out of your CMS, or wherever you have it set, and you’re populating this Data Layer. But once you’ve got that all set up then we want to be able to just reference that and push it into the beacon. So, we’ll assume that you already have a Data Layer and you’ve got your data in it. So then I go back to the page, and the main thing is to know then how to reference it, so if I bring up my console here, you’ll see that I have a reference to digital\Data.page- .pageInfo.pageName, and that really is this digital data object here, page, pageInfo, pageName and if I want to get technical I can put window in front of it as well. So I could put, window.digital\Data.- page.pageInfo.pageName and that is the same thing it’s pulling Basic Launch Analytics Test Page from the Data Layer right here. Basic Launch Analytics Test Page, okay, so that’s the first thing is to be able to know how to reference that, because then we’re gonna go into Launch, and we’re gonna go into Data Elements, and this is really where you are going to set it up. So we’re gonna Create a New Data Element, and we’re gonna call it Page Name, wow, Page Name okay and we’re going to leave it on the Core Extension, and we’re going to select the Data Element Type which is a JavaScript Variable, and then we just need the path to the variable, so I can actually just keep this real easy, and I’m going to copy that.
And put it in there.
And then I will save that, but at first I’ll Force lowercase value, that’s fine, and then I’ll save that to the library and build, see that I have a Working Library there, and that’s finished but I’m gonna do one more so let’s add Data Element, and this one is going to be the Site Section, also know as the Channel, and so I’m going to do another JavaScript Variable let’s go get it, actually so I could go to window.digitalData, page, category, primaryCategory, and again I had already typed that in so I am going to cheat here a little, and take that from here, and pop it into the variable there.
Okay, Save to Library and Build, and that’s done and that’s great, but that’s not going into my beacon yet and so now I need to decide how I’m going to take the data out of these data elements, the Page Name and Site Section data elements and push them into the beacon and there’s really two ways, one way would be in a Rules so I could go in and I could create a rule that assigns them to different props or eVars or Page Name and Channel and those kinds of things, or in this case what I’m gonna do is go back into Extensions, and go into Adobe Analytics, Configuration, and I’m gonna scroll down here to the Global Variables, now the reason why I’m gonna do this here, is because they are on every page, and there’s really no exceptions I’m going to set a Page Name and I’m going to set a section on every page, so if you’re gonna do it on every page, if it’s really gonna be global like that, then you can set it in the global variables otherwise you’re gonna want to go set it in a rule so that you can have more control over when you actually set that variable. In this case I will scroll down to the Page Name and instead of typing something in there, I can actually click on this icon and select the Page Name data element, Select. Super easy, and the Channel variable, I can do the same thing, for the Site Section data element. Done, except for the fact that it’s pretty good practice to go ahead and set the Page Name into an eVar, so I’m going to do that as well, and I happen to know that we have eVar four set up for this purpose, so I will set that as well, and we’ll set that to the Page Name as well. And it’s really just that easy, so we’ve actually taken the value out of the Data Layer, we’ve gone into Launch and we’ve created these data elements to store that data, and then in this case we’ve used the global variables to put them into Page Name and Channel and eVar4. So now let’s Save that to the Library and Build.
And now we should be able to go back to our page, and, get rid of the console there maybe, and let’s go ahead and refresh.
And there’s our hit, and fingers crossed now we have Page Name, we have that same Page Name in eVar4, and we have our Channel, also know as a Site Section, our company info pages, etc. So that is how you can actually use the Data Layer to get not only the Page Name and Channel but really any variables set and pushed in the beacon to Adobe Analytics. Thanks and good luck!
NOTE
The specific data layer used in this video may not be considered “best practice” for your organization. The concept of using a data layer for surfacing important data to your digital marketing solutions is best practice.
recommendation-more-help
b5d9c99f-be9f-4b96-8809-4e7d6ae353ba