1

I sell an online piano course. It's a single product that uses a single thank-you URL. On this thank-you page I want to track a transaction of 69 euro, quantity 1. The transaction ID and order ID need to be the samen and unique. How can I edit this code to make these ID's unique instead of '1' which I hardcoded now?

<script type="text/javascript">
pageTracker._addTrans(
"1", // required
"",
"69",
"",
"",
"",
"",
""
);
pageTracker._addItem(
"1", // required
"",
"Piano voor Beginners",
"Cursussen",
"69", // required
"1" //required
);
pageTracker._trackTrans();
</script>

1 Answer 1

3

Use

new Date().getTime(); 

as transaction id. It is rather unlikely that two persons book a course at the exact same millisecond (the js above produces a timestamp) and as long as you do not have a backend that generates unique transaction ids this will do. Actually you would assign the value of the above expression to a variable and use that:

<script type="text/javascript">
var transid =  new Date().getTime(); 
pageTracker._addTrans(
transid, // required
"",
"69",
"",
"",
"",
"",
""
);
pageTracker._addItem(
transid, // required
"",
"Piano voor Beginners",
"Cursussen",
"69", // required
"1" //required
);
pageTracker._trackTrans();
</script>

And you probably want to update your GA code, that looks like a really old version of the tracking code.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.