Michael Johns
Michael Johns

Reputation: 441

Issue Updating Adobe Analytics Variable Via Data Element in Dynamic Tag Manager - DTM

I have Adobe Analytics set-up as a tool in DTM. I have a "Page Name" data element which references a JS Object ( digitalData.page.pageInfo.pageID). In the tool set-up area, Global Variables, I have prop1 set to %Hostname%:%Page Name%. I also have under Pageviews and Content, Page Name set to %Hostname%:%Page Name%. Issue is at the point DTM sets the values here, it doesn't have access to the digitalData object (timing issue I'm trying to resolve below).

I have I had an issue with the object not being available when the DTM code was running so I put in a page load rule to suppress the Analytics call

s.abort = true;

and then in the 3rd party JavaScript area I put in code to check for the object to be detected and I get the expected value in my console output.

(function() { try { function checkObj(){ if (digitalData === null || digitalData === undefined) { setTimeout(checkObj(), 200); }else{ var pn = _satellite.getVar("Page Name"); console.log("----> object available - Page Name DE holds:" + pn); _satellite.track("Analytics Call"); return; } } checkObj(); } catch(e) {e.message(e);} })();

In the Direct Call Rule, "Analytics Call", I set the Adobe Page Name and prop1 again to %Hostname%:%Page Name% but the page name is still blank (only host name is output with colon) when the Analytics Call goes out?

In testing, I noticed in the Analytics Tool set-up, in the Pageviews and Content section, if I remove the values from the Page Name setting text box then nothing is output for pageName when the analytics call goes out?

So my issue is how do I get the Page Name and prop1 variables to update with the new value of the digitalData object when the analytics call goes out?

Upvotes: 0

Views: 1597

Answers (1)

Mark Stringham
Mark Stringham

Reputation: 421

Because this seems to be a race condition between when your DL object is available and when the page load rule executes, I would do the following:

  • Create a "global page load rule" for this use case instead of using the AA global configuration section within the tool.
  • Within the AA custom code section of the global page load rule set s.abort = true. This will allow you to wait for all of your other objects to load.
  • Call a direct call rule when all objects are loaded
  • Within the DC rule check for your DL object (pageName) and set AA vars.

Example code in DC rule

   if(Data_Layer_Obj)
   s.pageName = datalayer.pageName
}

Waiting for a Data Element here may be a challenge because of the timing issues between the page load rule and your data layer objects.

Hope this helps.

Upvotes: 1

Related Questions