Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- // TVA: ramener TTC sur HT 8%
- function arrHT(prixTTC){
- var chTVA = 1.08;
- var prixHT = prixTTC / chTVA;
- return prixHT.toFixed();
- }
- // Variables
- var _pArray = {{Commande - Produits}};
- var tAmount = {{Commande - Montant}};
- var tTax = {{Commande - Total TVA}};
- var tShipping = {{Commande - Total livraison}};
- // Tag
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
- })(window,document,'script','//www.google-analytics.com/analytics.js','ga');
- ga('create', {{ID - Google Analytics}});
- ga('require', 'ec');
- for (var j=0;j<_pArray.length;j++){
- ga('ec:addProduct', { // Provide product details in an productFieldObject.
- 'id': _pArray[j].sku, // Product ID (string).
- 'name': _pArray[j].name, // Product name (string).
- 'category': _pArray[j].category, // Product category (string).
- 'brand': '', // Product brand (string).
- 'variant': '', // Product variant (string).
- 'price': arrHT(_pArray[j].price), // Product price (currency).
- 'coupon': '', // Product coupon (string).
- 'quantity': _pArray[j].quantity, // Product quantity (number).
- 'dimension11': _pArray[j].livraison,
- 'metric2':1
- });
- }
- ga('ec:setAction', 'purchase', { // Transaction details are provided in an actionFieldObject.
- 'id': '{{Commande - ID}}', // (Required) Transaction id (string).
- 'affiliation': '{{Commande - Nom du magasin}}', // Affiliation (string).
- 'revenue': arrHT(tAmount), // Revenue (currency).
- 'tax': arrHT(tTax), // Tax (currency).
- 'shipping': arrHT(tShipping), // Shipping (currency).
- 'coupon': '', // Transaction coupon (string).
- 'dimension11': _pArray[0].livraison,
- 'metric12':1
- });
- ga('send', 'event',{
- 'eventCategory': 'eCom',
- 'eventAction': 'Achat',
- 'eventLabel': 'Confirmation'
- });
- </script>
Advertisement
Add Comment
Please, Sign In to add comment