Tracking Carts & Conversions on Abicart / Textalk via Google Tag Manager
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":
- items
- value
- transaction_id
- orderItem
Step 2: Next step is to make sure the following Triggers are defined with the following "Name" and "Event name":
- tws-article-added
- tws-purchase
Step 3: Now, add the following two Tags using the "Tag type": "Custom HTML":
- 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>
- 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.
Follow