Hey
I need to generate random number for a specific script
the script is google analytics eCommerce script
I am using Google tag manager to implant the script using custom html
I need the id of the transaction to be same for both parts marked in red
first thing I did was to generate a random number using a macro in GTM
problem is i get different numbers for each transaction
what i now thought of doing is
var randomnumber=Math.floor(Math.random()*11)
randomnumber
but again I am getting different numbers
Question is how can I generate a random number that will be the same for both id’s
Thank you for your time and help.
<script>
ga(‘require’, ‘ecommerce’);
ga(‘ecommerce:addTransaction’, {
[COLOR=”#FF0000″]‘id’: ‘{{trans id}}’, // Transaction ID. Required.
‘affiliation’: ‘category macro’, // Affiliation or store name.
‘revenue’: ‘3’, // Grand Total.
‘shipping’: ”, // Shipping.
‘tax’: ” // Tax.
});
ga(‘ecommerce:addItem’, {
[COLOR=”#FF0000″]‘id’: ‘{{trans id}}’, // Transaction ID. Required.
‘name’: ‘Fluffy Pink Bunnies’, // Product name. Required.
‘sku’: ‘DD23444’, // SKU/code.
‘category’: ‘Party Toys’, // Category or variation.
‘price’: ‘11.99’, // Unit price.
‘quantity’: ‘1’ // Quantity.
});
ga(‘ecommerce:send’);
</script>
Thanks in advance