How to Set TrackingServer Conditions to Adobe DTM Data Element

122 Views Asked by At

In Adobe DTM, we are trying to create a data element that returns a first party trackingserver value based on the site domain. Ultimately, we want to set this data element in the trackingserver field of the Experience Cloud ID service tool in DTM. We need to do this as we host multiple domains in one DTM profile.

Can anyone give me some tips on how I would go about doing this? For example, we want the data element to return "smetrics.domain1.com" for domain1.com and "smetrics.domain2.com" for domain2.com.

if(window.location.href.indexOf(".domain1.com") != -1)
{s.trackingServerSecure="smetrics.domain1.com"}

if(window.location.href.indexOf("domain2.com") != -1)
{s.trackingServerSecure="smetrics.domain2.com"}

This is what I have so far but pretty sure it's wrong because we don't want to set the s.trackingserversecure to be set in the data element itself.

1

There are 1 best solutions below

0
On BEST ANSWER

For Data Elements of type Custom Script, DTM wraps the code in a callback function, so DTM expects you to return a value.

Example:

Name: trackingServerSecure

Type: Custom Script

Code Box (Open Editor)

// default value to use if no domains match
var tss = "default.domain.com";

if(window.location.hostname.indexOf(".domain1.com") != -1) {
    tss = "smetrics.domain1.com";
}
if(window.location.hostname.indexOf("domain2.com") != -1) {
    tss="smetrics.domain2.com";
}

return tss;

Then, in the Experience Cloud ID Service Tool Config, use %trackingServerSecure% in the Tracking Server field.