Lookup type function in DTM | Community
Skip to main content
trench999
New Participant
October 16, 2015
Solved

Lookup type function in DTM

  • October 16, 2015
  • 4 replies
  • 2755 views

On every AEM page we put a global Google Analytics property ID and for many subdomains/subdirectories we place a local site ID in addition.  Google Tag Manager uses a lookup table to map page urls to variables.  We need to setup something like this in DTM.  What is the best way to do this?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by a_d_a_m_

The trick is that you'd need to use a data element to populate the Google Analytics account ID, however it isn't possible in DTM (by default).  You could write a work around to allow DTM to use a data element.  Then you'd write some custom code in the data element to have it return the correct account ID.

Another option would be to add multiple Google Analytics tools and in the custom code you can "return false" if the domain doesn't match the correct URL.  Not ideal, but it is a solution.

4 replies

a_d_a_m_
a_d_a_m_Accepted solution
New Participant
October 16, 2015

The trick is that you'd need to use a data element to populate the Google Analytics account ID, however it isn't possible in DTM (by default).  You could write a work around to allow DTM to use a data element.  Then you'd write some custom code in the data element to have it return the correct account ID.

Another option would be to add multiple Google Analytics tools and in the custom code you can "return false" if the domain doesn't match the correct URL.  Not ideal, but it is a solution.

trench999
trench999Author
New Participant
October 16, 2015

If I understand, we would populate a data element based on a URL or DOM element on the page then write a JS routine to look up a value.  I guess we could put a page property on each page that was inheritable.  The property could be put into a JSON object on the page and read into a data element directly with no DTM JS coding.  Would that work?

Rahsing
New Participant
October 16, 2015

I think so yes.

Could you let us know if you tried it and what the result was?

Sorry for the delayed response.

Rahul

Rahsing
New Participant
October 16, 2015

I think the method using data elements as described by Adam should probably work.

In case you need it, here's some documentation on how to set up data elements.