jroakes

Gtag Implementation

Mar 4th, 2019
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Detailed information here:
  2. https://developers.google.com/analytics/devguides/collection/gtagjs/enhanced-ecommerce
  3.  
  4. // Include in all pages
  5. <!-- Global site tag (gtag.js) - Google Analytics -->
  6. <script async src="https://www.googletagmanager.com/gtag/js?id=UA-6378212-24"></script>
  7. <script>
  8.   window.dataLayer = window.dataLayer || [];
  9.   function gtag(){dataLayer.push(arguments);}
  10.   gtag('js', new Date());
  11.  
  12.   gtag('config', 'UA-6378212-24', {
  13.     'linker': {
  14.       'domains': ['gsx.org', 'asisonline.org', 'wyndhamjade.com', 'mcisemi.com']
  15.      }
  16. });
  17.    
  18. </script>
  19.  
  20.  
  21. // Include as needed by transaction step.
  22.  
  23. // Add to Cart ///////////////////////////
  24. gtag('event', 'add_to_cart', {
  25.   "items": [
  26.     {
  27.       "id": "P12345",
  28.       "name": "Expo-Only Pass: Nonmember",
  29.       "quantity": 2,
  30.       "price": '2.0'
  31.     }
  32.   ]
  33. });
  34.  
  35.  
  36. // Begin Checkout ///////////////////////////
  37. gtag('event', 'begin_checkout', {
  38.   "items": [
  39.     {
  40.       "id": "P12345",
  41.       "name": "Expo-Only Pass: Nonmember",
  42.       "quantity": 2,
  43.       "price": '2.0'
  44.     }
  45.   ],
  46.   "coupon": ""
  47. });
  48.  
  49.  
  50. // Purchase Steps //////////////////////////////////
  51.  
  52. 1. Registration /asis2019/registration.html
  53. gtag('event', 'checkout_progress', {
  54.   "items": [
  55.     {
  56.       "id": "P12345",
  57.       "name": "Expo-Only Pass: Nonmember",
  58.       "quantity": 2,
  59.       "price": '2.0'
  60.     }
  61.   ],
  62.   "checkout_step": 1,
  63.   "checkout_option": "Registration"
  64. });
  65.  
  66.  
  67. 2. Profile /asis2019/profile.html
  68. gtag('event', 'checkout_progress', {
  69.   "items": [
  70.     {
  71.       "id": "P12345",
  72.       "name": "Expo-Only Pass: Nonmember",
  73.       "quantity": 2,
  74.       "price": '2.0'
  75.     }
  76.   ],
  77.   "checkout_step": 2,
  78.   "checkout_option": "Profile"
  79. });
  80.  
  81.  
  82. 3. Survey /asis2019/survey.html
  83. gtag('event', 'checkout_progress', {
  84.   "items": [
  85.     {
  86.       "id": "P12345",
  87.       "name": "Expo-Only Pass: Nonmember",
  88.       "quantity": 2,
  89.       "price": '2.0'
  90.     }
  91.   ],
  92.   "checkout_step": 3,
  93.   "checkout_option": "Survey"
  94. });
  95.  
  96.  
  97. 4. Payment /asis2019/payment.html
  98. gtag('event', 'checkout_progress', {
  99.   "items": [
  100.     {
  101.       "id": "P12345",
  102.       "name": "Expo-Only Pass: Nonmember",
  103.       "quantity": 2,
  104.       "price": '2.0'
  105.     }
  106.   ],
  107.   "checkout_step": 4,
  108.   "checkout_option": "Payment"
  109. });
  110.  
  111.  
  112. // Transaction //////////////////////////////////
  113.  
  114. gtag('event', 'purchase', {
  115.   "transaction_id": "24.031608523954162",
  116.   "affiliation": "GSX Registration",
  117.   "coupon": "VENDORCOUPON",
  118.   "value": 23.07,
  119.   "currency": "USD",
  120.   "tax": 1.24,
  121.   "shipping": 0,
  122.   "items": [
  123.     {
  124.       "id": "P12345",
  125.       "name": "Expo-Only Pass: Nonmember",
  126.       "quantity": 2,
  127.       "price": '2.0'
  128.     },
  129.     {
  130.       "id": "P67890",
  131.       "name": " All-Access Pass: Nonmember",
  132.       "quantity": 1,
  133.       "price": '3.0'
  134.     }
  135.   ]
  136. });
Add Comment
Please, Sign In to add comment