Equally late on this answer, but I'm hoping this saves someone a headache. I'm relatively new at all of this, so bare with me if I'm a bit off on explaining my solution. I was running into a number of similar issues with GTM. I believe is stems from the way GTM converts the document.write
command.
The first problem I had with gtm and ExactTarget was the final document.write
command would cut off everything after <system>
when I would pass it in through multiple document.write
commands, as the ExactTarget's JavaScript conversion documentation tells you too. This problem was fixed by putting it into one string, but opened up another problem.
The second problem was GTM would insert data-ps-id=2
into my <system>
tag so it would look like <system data-ps-id=2>
. Since you are passing back a query to exact target, aspx?xml=
, it would think that the equal sign in data-ps-id=2
is another data point you're trying to pass back to ExactTarget which would then screw up everything else you pass after it. My solution to this was to use encodeURI()
on the final string. See the final solution below:
var h = 'https://click.exacttarget.com/conversion.aspx?xml=';
h += '<system><system_name>tracking</system_name><action>conversion</action>';
h += '<member_id>' + memberid + '</member_id><job_id>' + jobid + '</job_id>';
h += '<sub_id>' + SubscriberID + '</sub_id><email></email><list>' + listid + '</list>';
h += '<BatchID></BatchID><original_link_id>' + urlid + '</original_link_id>';
h += '<conversion_link_id>' + convid + '</conversion_link_id><link_alias>';
h += linkalias + '</link_alias><display_order>' + convid + '</display_order>';
h += '<data_set>' + sData + '</data_set></system>';
document.write('<img src="' + encodeURI(h) + '" height="1" width="1" />');
An additional note, I also ran into some issues with single quotes, double quotes in GTM, hence the reason I use the single then double. ExactTarget suggests this to set your dataset:
dataset=dataset+"<data amt=\"1\" unit=\"Dollars\" accumulate=\"true\">
My dataset, or sData variable looked like this when I set it:
dataSet+='<data amt="1" unit="Sales Unit" accumulate="true"/>';