Expand my Community achievements bar.

SOLVED

Conversion Tracking with Variables

Avatar

Level 1

Hello,

I want to integrate a Tracking Pixel with variables:

<iframe src="https://tbs.tradedoubler.com/report?organization=7362551&event=917835654&orderNumber=[VARIABLE]&orde..." height="1" width="1" border="0"/>

The variables [VARIABLE], [Transaction_value] and [Currency] are still on my site in the data layer:

[variable] = _satellite.getVar("transactionID")

[Transaction_value] = _satellite.getVar("transactionRevenue")

[Currency] = _satellite.getVar("transactionCurrency")

1. How can I get this data layer veariables in the Conversion Code?

2. What implementation method should I use in the rule (sequentiell HTML, sequentiell java, not sequentiell)?

Many thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi,

The pixel you provided is an HTML iframe. By default, that tag does not support dynamic variables. In order to dynamically populate a variable, you will need to use some sort of script to populate the URL. Below is one way you can accomplish this, but you can find others by doing a quick search for "dynamically populating iframe src".

In this case, you'd deploy an <iframe> tag, preferably with a unique id. Then you'd deploy a version of the script below where you populate the url that will then be dynamically injected into the iframe. In the script below, you should be able to use  _satellite_getVar() to retrieve the value of DTM data elements.

window.onload = function() { var url; //You can get this url dynamically from an ajax request or from a form etc 

// To Do : A function to populate url with a valid url from any method you prefer. 

// Set an ID for the iframe. Let us give that an id of myframe

document.getElementById("myframe").setAttribute("src", url); }

View solution in original post

1 Reply

Avatar

Correct answer by
Level 10

Hi,

The pixel you provided is an HTML iframe. By default, that tag does not support dynamic variables. In order to dynamically populate a variable, you will need to use some sort of script to populate the URL. Below is one way you can accomplish this, but you can find others by doing a quick search for "dynamically populating iframe src".

In this case, you'd deploy an <iframe> tag, preferably with a unique id. Then you'd deploy a version of the script below where you populate the url that will then be dynamically injected into the iframe. In the script below, you should be able to use  _satellite_getVar() to retrieve the value of DTM data elements.

window.onload = function() { var url; //You can get this url dynamically from an ajax request or from a form etc 

// To Do : A function to populate url with a valid url from any method you prefer. 

// Set an ID for the iframe. Let us give that an id of myframe

document.getElementById("myframe").setAttribute("src", url); }