Expand my Community achievements bar.

SOLVED

Third party tag - using Data Elements

Avatar

Level 3

We are currently using Wordpress where we have a plugin to insert third party tags. There we can use shortcodes for parameters such as order id. E.g.:

<img src="https://someurl.com/?c=stats&orderid=[orderid]" width="1" height="1">

We need to move a lot of pixels from Wordpress to DTM and I'm looking for an easy way for Marketers to do it, without overwriting the code like this: 

document.write('<img src="https://someurl.com/?c=stats&orderid=' + _satellite.getVar('orderid') + '" width="1" height="1">');

An easier way would be something like this (this time, the Sequential HTML would be used):

<img src="https://someurl.com/?c=stats&orderid=<script>_satellite.getVar('orderid');</script>" width="1" height="1">

It would be easier as you would need to replace the '[orderid] with '<script>_satellite.getVar('orderid');</script>' This however simply returns the '<script>_satellite.getVar('orderid');</script>' for the orderid parameter.

Any ideas/hints?

1 Accepted Solution

Avatar

Correct answer by
Level 3

That works. Thank you Cleve.

View solution in original post

5 Replies

Avatar

Level 2

In the sequential HTML you can pull in the Data Element value by wrapping the name with %%. Example: 

  1. <img src="https://someurl.com/?c=stats&orderid=%orderid%" width="1" height="1">

Avatar

Correct answer by
Level 3

That works. Thank you Cleve.

Avatar

Level 2

How do you do this with Non-Sequential HTML for event-based rules?

Avatar

Level 10

Hi Laura ,

Non- sequential HTML tags are injected as hidden iframes Hence iframe can’t get all the same information the parent page can. This includes many data elements- for security reasons, it can’t reference a data element that pulls from Custom JS or JS objects. If you’re referencing a data element, you need to use “%dataElementName%” rather than “_satellite.getVar(“dataElementName”)” as  _satellite method doesn't work inside iframe. This isn’t the most supported usage, so definitely test it thoroughly.

However the other round to this add your tag as Non Sequential Javascript like below:

var dcIMG = document.createElement('img'); dcIMG.setAttribute('src',"https://someurl.com/?c=stats&orderid="+ _satellite.getVar('orderid') ); dcIMG.setAttribute('height','1'); dcIMG.setAttribute('width','1'); document.body.appendChild(dcIMG);

Thanks & Regards 

Parit Mittal

Avatar

Level 2

Hi Parit,

Thanks so much for your response. This is a similar solution to the one I had as well, but I needed to place the code within the "custom rule" section at the top of the tag (and set it to 'return true' to ensure it fires) in order for this to work. Without placing it here I was getting a HTML header content-type error when I tried to append the tag. 

Although not clean, this solution seems to be working now. 

Thanks again,

Laura