Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1. <!-- Google Analytics Base Code -->
  2. <script async src="https://www.googletagmanager.com/gtag/js?id=UA-126316797-1"></script>
  3. <script>
  4. window.dataLayer = window.dataLayer || [];
  5. function gtag(){dataLayer.push(arguments);}
  6. gtag('js', new Date());
  7. gtag('config', 'UA-126316797-1', { // Paste your property ID here from the example gtag script - note it ALSO goes above!
  8. 'linker': {
  9. 'domains': [ 'lab41.co', 'kathreadwrites.com', 'commerce.thrivecart.com', 'checkout.lab41.co'], // Change these to point to your multiple domains
  10. 'accept_incoming': true
  11. }
  12. });
  13. </script>
  14. <!-- Google Analytics Base Code -->
  15. <!-- Google Analytics Product Info Code -->
  16. <script>
  17. (function() {
  18. if(typeof _thrive_order === 'undefined') return;
  19. var items = [];
  20. if(typeof _thrive_order.order.product !== 'undefined') { // Product block
  21. items.push({
  22. 'id': _thrive_order.order.product.id,
  23. 'name': _thrive_order.order.product.name,
  24. 'quantity': _thrive_order.order.product.quantity,
  25. 'price': _thrive_order.order.product.total_readable
  26. });
  27. }
  28. if(typeof _thrive_order.order.bump !== 'undefined') { // Bump block
  29. items.push({
  30. 'id': _thrive_order.order.bump.id,
  31. 'name': _thrive_order.order.bump.name,
  32. 'quantity': _thrive_order.order.bump.quantity,
  33. 'price': _thrive_order.order.bump.total_readable
  34. });
  35. }
  36. var f = function(type) {
  37. if(typeof _thrive_order.order[type] !== 'undefined') {
  38. for(var x in _thrive_order.order[type]) {
  39. if(!_thrive_order.order[type].hasOwnProperty(x)) continue;
  40. items.push({
  41. 'id': _thrive_order.order[type][x].id,
  42. 'name': _thrive_order.order[type][x].name,
  43. 'quantity': _thrive_order.order[type][x].quantity,
  44. 'price': _thrive_order.order[type][x].total_readable
  45. });
  46. }
  47. }
  48. };
  49. f('upsells'); // Handle all upsells
  50. f('downsells'); // Handle all downsells
  51. gtag('event', 'purchase', {
  52. 'transaction_id': _thrive_order.order.invoice_id,
  53. 'value': _thrive_order.order.total_readable,
  54. 'currency': _thrive_order.order.currency,
  55. 'tax': _thrive_order.order.tax_readable,
  56. 'shipping': _thrive_order.order.shipping,
  57. 'items': items
  58. });
  59. })();
  60. </script>
  61. <!-- Google Analytics Product Info Code -->
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement