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?
Solved! Go to Solution.
Views
Replies
Total Likes
That works. Thank you Cleve.
Views
Replies
Total Likes
In the sequential HTML you can pull in the Data Element value by wrapping the name with %%. Example:
<img src="https://someurl.com/?c=stats&orderid=%orderid%" width="1" height="1">
That works. Thank you Cleve.
Views
Replies
Total Likes
How do you do this with Non-Sequential HTML for event-based rules?
Views
Replies
Total Likes
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
Views
Replies
Total Likes
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
Views
Replies
Total Likes
Views
Likes
Replies