Skip to content

Tracking Carts & Conversions on Abicart / Textalk via Google Tag Manager

Here's a guide explaining how you can track carts and conversions on the Textalk platform via Google Tag Manager (GTM).

Step 1: Ensure the following User-Defined Variables are defined in GTM with the following "Name" and "Data Layer Variable Name":

  1. items
  2. value
  3. transaction_id
  4. orderItem

  

Step 2: Next step is to make sure the following Triggers are defined with the following "Name" and "Event name":

  1. tws-article-added
  2. tws-purchase

Step 3: Now, add the following two Tags using the "Tag type": "Custom HTML":

  1. This is the code for conversion tracking and should use "tws-purchase" Trigger as the "Firing Triggers":

    For Google Analytics 4

    <script>
      var productArray = [];
      var dynamicProductArray = {{ items }};
      for(i=0;i<dynamicProductArray.length;i++) {
          productArray.push(dynamicProductArray[i]["item_id"]);
      }
    
      hrq = window.hrq || [];
      hrq.push(["trackConversion", {
            total: "{{ value }}",
            orderNumber: "{{ transaction_id }}",
            productNumbers: productArray
      }]);
    </script>
    

  2. This is the code for cart tracking and should use "tws-article-added" Trigger as the "Firing Triggers":

    <script>
      var basketItem = {{orderItem}};
      hrq = window.hrq || [];
      hrq.push(function() {
          ADDWISH_PARTNER_NS.api.cart.addProduct({
              productNumber: basketItem.articleNumber
          });
      });
    </script>
    

Step 4: Finally, make sure to Submit and Publish your changes.