Get Marketing Tag to Fire Once per Session in Adobe DTM

I was recently asked by a client to have a 3rd party tag fire once onClick when a user selected an item to customize the product they were looking at. This posting will describe the steps you need to take to make sure that that happens.

The first thing you will need to do is log into Adobe DTM and add your 3rd party tag in. Once that is done, you will then need to create a data element to house the logic that will determine whether to fire the tag or not depending on the users actions.

Name: recognizedUserAction
Type: Custom Script
Default Value: false
Remember this value for: Session

You will then need to open the code editor for the Custom Script and put the following:

var dtm_rUA = _satellite.readCookie('dtm_ev');
return dtm_rUA;

Save the Data Element.

Then, go to your event based Rule where you have your 3rd Party tag that needs this indicator.

Go to Conditions, and for Criteria, select Data > Data Element Value, and click the Add Criteria button.

Then in the Data Element dropdown that appears, choose “recognizedUserAction”, and for the Value, put in false.

Save the rule and Approve/Publish the Data Element and event based Rule. VoilĂ !

Now to understand what the above code is doing. This looks at the cookie dtm_ev and returns the value of either true of false depending on the cookie. If the cookie is found, we know that the user is recognized while a false value shows that the user is not recognized.

The cookie is set to expire 1 day into the future and gets adjusted every time the page is loaded. The Data Element is also set to remember the returned value for “Session” life-cycle. This means as long as a visitor does not delete the cookie, it should only trigger the event based rule once. This also provides coverage if the user decides to leave the site and come back. If they do that after 1 day, the cookie will have expired and the event based rule will trigger.

Posted in Adobe, Dynamic Tag Manager