Created
October 13, 2014 11:48
-
-
Save SearchStar/be2a51c5cbe69bf67499 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript"> | |
var orderId = '12345'; | |
var OrderTotal = 100.25; | |
var attraction = 'new'; | |
var ShippingCity = 'wilts'; | |
var ShippingCountyState = 'london'; | |
var ShippingCountry = 'england'; | |
var ShippingMethod = 3.99; | |
var OrderTax = 11.99; | |
var ItemSKU = ["1234567890", "0987654321", "123456789012"]; | |
var ItemName = ["newhat", "newcoats", "newtoys"]; | |
var ItemCategory = ["newhats", "newcoats", "newtoys"]; | |
var ItemPrice = [3.99, 2.99, 2.88]; | |
var ItemQuantity = [2, 1, 5]; | |
var productArr = []; | |
var _gaq = _gaq || []; | |
_gaq.push(['_setAccount', 'UA-XXXXX-X']); | |
_gaq.push(['_trackPageview']); | |
_gaq.push(['_addTrans', | |
''+ orderId +'', // transaction ID - required | |
''+ attraction +'', // affiliation or store name | |
''+ OrderTotal +'', // total - required | |
''+ OrderTax +'', // tax | |
''+ ShippingMethod +'', // shipping | |
''+ ShippingCity +'', // city | |
''+ ShippingCountyState +'' // state or province | |
''+ ShippingCountry +'', // country | |
]); | |
for (var i = 0; i < ItemSKU.length; i++) | |
{ | |
products = '_gaq.push(["_addItem"', | |
''+ orderId +'', | |
''+ ItemSKU[i] +'', | |
''+ ItemName[i] +'', | |
''+ ItemCategory[i] +'', | |
''+ ItemPrice[i] +'', | |
''+ ItemQuantity[i] +'' | |
'])'; | |
} | |
productArr[i] = products; | |
} | |
_gaq.push(['_trackTrans']); | |
(function() { | |
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; | |
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; | |
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment