Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // More developer details: https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#measuring-checkout
- // On each page//////////////////////////////////
- (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', 'UA-6378212-24', 'auto', 'gsxTracker', {'allowLinker': true});
- ga('gsxTracker.require', 'ec');
- ga('gsxTracker.require', 'linker');
- ga('gsxTracker.linker:autoLink', ['gsx.org', 'asisonline.org', 'wyndhamjade.com'] );
- ga('gsxTracker.send', 'pageview'); //(On each page unless sent at step below)
- // Adding Products //////////////////////////////////
- function addToCart(product) {
- ga('gsxTracker.ec:addProduct', {
- 'id': product.id,
- 'name': product.name,
- 'category': product.category,
- 'brand': product.brand,
- 'variant': product.variant,
- 'price': product.price,
- 'quantity': product.qty
- });
- ga('gsxTracker.ec:setAction', 'add');
- ga('gsxTracker.send', 'event', 'UX', 'click', 'add to cart'); // Send data using an event.
- }
- // Checkout //////////////////////////////////
- /**
- * Called when the user begins the checkout process.
- * @param {Array} cart An array representing the user's shopping cart.
- */
- function checkout(cart) {
- for(var i = 0; i < cart.length; i++) {
- var product = cart[i];
- ga('gsxTracker.ec:addProduct', {
- 'id': product.id,
- 'name': product.name,
- 'category': product.category,
- 'brand': product.brand,
- 'variant': product.variant,
- 'price': product.price,
- 'quantity': product.qty
- });
- }
- }
- // Purchase Steps //////////////////////////////////
- 1. Registration /asis2019/registration.html
- ga('gsxTracker.ec:setAction','checkout', {
- 'step': 1,
- 'option': 'Registration'
- });
- ga('gsxTracker.send', 'pageview');
- 2. Profile /asis2019/profile.html
- ga('gsxTracker.ec:setAction','checkout', {
- 'step': 2,
- 'option': 'Profile'
- });
- ga('gsxTracker.send', 'pageview');
- 3. Survey /asis2019/survey.html
- ga('gsxTracker.ec:setAction','checkout', {
- 'step': 3,
- 'option': 'Survey'
- });
- ga('gsxTracker.send', 'pageview');
- 4. Payment /asis2019/payment.html
- ga('gsxTracker.ec:setAction','checkout', {
- 'step': 4,
- 'option': 'Payment'
- });
- ga('gsxTracker.send', 'pageview');
- // Purchase / Confirmation //////////////////////////////////
- ga('gsxTracker.ec:addProduct', {
- 'id': 'P12345',
- 'name': 'Android Warhol T-Shirt',
- 'category': 'Apparel',
- 'brand': 'Google',
- 'variant': 'black',
- 'price': '29.20',
- 'quantity': 1
- });
- // Transaction level information is provided via an actionFieldObject.
- ga('gsxTracker.ec:setAction', 'purchase', {
- 'id': 'T12345',
- 'affiliation': 'GXS Registration',
- 'revenue': '37.39',
- 'tax': '2.85',
- 'shipping': '5.34',
- 'coupon': 'SUMMER2013' // User added a coupon at checkout.
- });
- ga('gsxTracker.send', 'pageview');
Add Comment
Please, Sign In to add comment