Google Tag Manager Ecommerce Enhancement conversation on Shopify Website

Google Tag Manager Ecommerce Enhancement conversation on Shopify Website

0 Shares
0
0
0
0
0
0
0

Nowadays all clients asking for Ecommerce customer Enhancement update to capture data at Google Tag Manager Layer

First, we have to put theGlobal site tag on the theme.liquid

<!-- Global site tag (gtag.js) - Google Ads: 11111111 -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-11111111"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'AW-111111111', {'allow_enhanced_conversions':true});
</script>

Below whole code we have to put on Shopify admin.
Setting ➔ Checkout ➔ Order processing

https://yourdomain.myshopify.com/admin/settings/checkout

enhanced_conversion_data variable where you have to add all additional details which you require

<!-- Global site tag (gtag.js) - Google Ads: 11111111 -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-11111111"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
  gtag('config', 'AW-111111111', {'allow_enhanced_conversions':true});
</script>

<script>
  var enhanced_conversion_data = {
    "email": '{{ customer.email }}',
    "phone_number": '{{ customer.phone }}',
    "first_name": '{{ customer.first_name }}',
    "last_name": '{{ customer.last_name }}',
    "home_address": {
      "street": '{{ shipping_address.street }}',
      "city":'{{ customer_address.city }}',
      "region": '{{ customer_address.country_code }}',
      "postal_code": '{{ customer_address.zip }}',
      "country": '{{ customer_address.country }}'
    }
  };
</script>

{% if first_time_accessed %}
<!-- Event snippet for Purchase conversion page -->
<script>
  gtag('event', 'conversion', {
   		 'send_to': 'AW-111111111/xxxxxxxxxxxx',
  		 'value':    {{ checkout.subtotal_price | divided_by: 100.0 }},
       'currency': '{{ currency }}',
       'transaction_id': '{{ order_number }}'
       });
</script>
{% endif %}