How to setup Bronto Tracking Pixels with JavaScript

1
How to setup Bronto Tracking Pixels with JavaScript

Recently at my job, I had to setup Bronto email tracking pixels on our order confirmation page. The tracking pixels came in the form of an image tag and had to be populated with some values from our shopping cart. The values (invoice number and order amount) are passed from the order confirmation page using hidden fields.

<input name="InvID" type="hidden" id="InvID" value="12345" />
<input name="Tot" type="hidden" id="Tot" value="69.9900" />

I then used JavaScript to extract the values in the hidden inputs and assigned them variables.

var InvoID = document.getElementById("InvID").value;
var SubTotal = document.getElementById("Tot").value;

Then, I used document.write to create an image tag on the fly with the correct values filled out using JavaScript concatenation.

document.write("<img src='http://bronto.com?type=$&description="+InvItemName+"&money="+ItemPrice+">'");

I have recently found that if you have apostrophes in your code, it will break the above tracking script. A way around this would be to use a string replace function like this:

InvItemName.replace(/'/i,"")

*NOTICE: The values in the scripts are dummy values, as I had to hide some confidential account data. The code is just to show as an example, but its pretty easy to setup. You can use similar techniques to setup Google, MSN, Yahoo, and other types of tracking pixels.

  1. Hi Jake,

    We are a newly bronto client and we are currently having a problem with their tracking conversion code because it will not dynamically track revenue of our campaign. Your blog has been referred to us but unfortunately we are not that expert in javascripting. We are a yahoo!store. Can you help us?

    Peace

LEAVE A REPLY