Employing tracking in Shoptet using GTM

Employing tracking in Shoptet using GTM

 

 

A guide for the GTM setup for e-shops in Shoptet.

  1. create an account at https://tagmanager.google.com/#/home
  2. add your website. Tag Manager will generate for you a code from which to take your ID. Example: GTM-XXXXXX
  3. insert your GTM ID in Shoptet administration in the box for Google Tag Manager ID and tick off the use of Google Data Layer Helper
  4. in Tag Manager create a tag for click tracking “Affil Dognet – click tracking“ as custom HTML where to insert the click tracking code (the code to be supplied by us). The trigger is every page (All pages)
  5. in Tag Manager create trigger ”DOM ready”
  6. create a tag for tracking sales ”Affil Dognet – sale tracking“ as custom HTML where to insert the sale tracking code (the code to be supplied by us). The trigger is DOM ready. In enhanced settings, set up the tag so as to be run in any event.
  7. in this step you have already created 2 tags and 1 trigger
  8. configurate Variables so as to have checked off all in Pages, Utilities, Clicks and Forms
  9. publish all changes

If necessary, contact us, we can also set up GTM for you 😉

 

Click tracking code

”XXXXXXXXXXX“ needs to be substituted for your account ID

“YYYYYYY“ needs to be substituted for your campaign ID

 

<div id='papPlaceholder'></div>
 
<script type="text/javascript">
  (function(d,t) {
    var script = d.createElement(t); script.id= 'pap_x2s6df8d'; script.async = true;
    script.src = '//login.dognet.sk/scripts/fj27g82d';
    script.onload = script.onreadystatechange = function() {
      var rs = this.readyState; if (rs && (rs != 'complete') && (rs != 'loaded')) return;
      PostAffTracker.setAccountId('XXXXXXXX');
      try { var CampaignID='YYYYYYYY';
	  PostAffTracker.track(); } catch (e) {}
    }
    var placeholder = document.getElementById('papPlaceholder');
    placeholder.parentNode.insertBefore(script, placeholder);
    placeholder.parentNode.removeChild(placeholder);
  })(document, 'script');
</script>

 


Sale tracking code

“XXXXXXXX“ needs to be substituted for your account ID “YYYYYYYY“ needs to be substituted for your campaign ID  
<div id='papSaleTrackingPlaceholder'></div>
<script type="text/javascript">
  (function(d,t) {
    var script = d.createElement(t); script.id= 'pap_x2s6df8d'; script.async = true;
    script.src = '//login.dognet.sk/scripts/fj27g82d';
    script.onload = script.onreadystatechange = function() {
        var rs = this.readyState; if (rs && (rs != 'complete') && (rs != 'loaded')) return;
        //DECLARATION OF DATALAYER FOR DATAHELPER
        var dataHelper = new DataLayerHelper(dataLayer);
        //RUN TRACKING ONLY ON THANK YOU PAGE  
        if (dataHelper.get('shoptet.pageType') == 'thankYou') { 
          //CHECK IF COUPON CODE HAS BEEN USED
          var shoptetCouponCode = "";
          console.log(dataHelper.get('shoptet.order.discountCoupons'));
          if (dataHelper.get('shoptet.order.discountCoupons').length != 0) {
            var shoptetDiscountCoupons = dataHelper.get('shoptet.order.discountCoupons');
            shoptetCouponCode = shoptetDiscountCoupons[0].code;
          }          
          //CREATE LIST OF PRODUCT IDs FORM PRODUCT ARRAY
          var shoptetProductList = "";
          var shoptetProducts = dataHelper.get('shoptet.order.content');
          var tmpY = 0;          
          for (tmpY=0; tmpY<shoptetProducts.length; tmpY++) {
            shoptetProductList += shoptetProducts[tmpY].id;
            shoptetProductList += ", ";
          }       
          //ORDER INFORMATION FOR TRACKING
          PostAffTracker.setAccountId('XXXXXXXX');
          var sale = PostAffTracker.createSale();
		      sale.setCampaignID('YYYYYYYY');
          sale.setTotalCost(dataHelper.get('shoptet.order.netto'));
		      sale.setOrderID(dataHelper.get('shoptet.order.orderNo'));
		      sale.setProductID(shoptetProductList);
		      sale.setCoupon(shoptetCouponCode);
		      sale.setCurrency(dataHelper.get('shoptet.order.currencyCode'));
          
          try { PostAffTracker.track(); } catch (e) {}
          
        }
    }
    var placeholder = document.getElementById('papSaleTrackingPlaceholder');
    placeholder.parentNode.insertBefore(script, placeholder);
    placeholder.parentNode.removeChild(placeholder);
  })(document, 'script');
</script>
Katka Novotná

Viac ako dva roky som pracovala na pozícií e-commerce marketér a zvyšovala som obraty rôznym eshopom. Niektoré z nich sa vyšplhali až na Shop Roku (ocenenie od Heureka.sk). Mám skúsenosti s PPC Adwords aj Facebook. Analytics mi je veľmi blízky. Pre reklamnú agentúru Wiktor Leo Burnett som pomáhala s UX/UI webových projektov a aplikácií pre veľkých klientov. Vo voľnom čase tvorím webové stránky založené prevažne na WordPresse.

More articles that might interest you

Which campaigns are available in our network?