MaximusDecimusMeridius
MaximusDecimusMeridius

Reputation: 135

Dynamic Tag Management - Storing

We're in the process of moving to DTM implementation. We have several variables that are being defined on page. I understand I can make these variables available in DTM through data elements. Can I simply set up a data elem

So set data elements

%prop1% = s.prop1
%prop2% = s.prop2
etc

And then under global rules set

s.prop1 = %s.prop1%
s.prop2 = %s.prop2% 
etc

for every single evar, sprop, event, product so they populate whenever they are set on a particular page. Good idea or terrible idea? It seems like a pretty bulky approach which raises some alarm bells. Another option would be to write something that pushes everything to the datalayer, but that seems like essentially the same approach with a redundant step when they can be grabbed directly.

Basically I want DTM to access any and all variables that are currently being set with on-page code, and my understanding is that in order to do that they must be stored in a data element first. Does anyone have any insight into this?

Upvotes: 0

Views: 1291

Answers (2)

Mark Stringham
Mark Stringham

Reputation: 421

If you are moving from a legacy s_code implementation to DTM, it is a good best practice to remove all existing "on page" code (including the reference to the s_code file) and create a "data layer" that contains the data from the eVars and props on the page. Then DTM can reference the object on the page and you can create data elements that map to variables.

Here's an example of a data layer:

<script type="text/javascript">

DDO = {} // Data Layer Object Created
DDO.specVersion = "1.0";
DDO.pageData = {
"pageName":"My Page Name",
"pageSiteSection":"Home",
"pageType":"Section Front",
"pageHier":"DTM Test|Home|Section Front"
},
 DDO.siteData = {
"siteCountry":"us",
 "siteRegion":"unknown",
 "siteLanguage":"en",
 "siteFormat":"Desktop"
}

</script>

The next step would be to create data elements that directly reference the values in the object. For example, if I wanted to create a data element that mapped to the page name element in my data layer I would do the following in DTM:

  • Create a new data element called "pageName"
  • Select the type as "JS Object"
  • In the path field I will reference the path to the page name in my data layer example above - DDO.pageData.pageName
  • Save the data element

Now this data element can be referenced in any variable field within any rule by simply typing a '%'. DTM will find any existing data elements and you can select them.

I also wrote about a simple script you can add to your implementation to help with your data layer validation.Validate your DTM Data Layer with this simple script

Hope this helps.

Upvotes: 1

BrettAHale
BrettAHale

Reputation: 800

I use this spec for setting up data layers: Data Layer Standard

We create data elements for each key that we use from the standard data layer. For example, page name is stored here

digitalData.page.pageInfo.pageName

We create a data element and standardize the names to this format "page.pageInfo.pageName" Within each variable field, you access it with the %page.pageInfo.pageName% notation. Also, within javascript of rule tags, you can use this:

_satellite.getVar('page.pageInfo.pageName')

It's a bit unwieldy at times but it allows you to separate the development of the data layer and tag manager tags completely.

One thing to note, make sure your data layer is complete and loaded before you call the satellite library.

Upvotes: 1

Related Questions