Enhanced Google Ads Conversion Script for Shopify

Google is rolling out  Enhanced Conversion Scripts which helps to improve conversion accuracy measurement; this adds extra data to conversion with SHA256 hashing for personal data attributes.

Below is a sample script for Shopify, for sending customer data along with eCommerce data.

Before starting be sure to enable the "manual" tagging option at Google Ads enhanced conversion settings also accept Google's terms and conditions.

And place below script at - Settings > Checkout > Additional Scripts

<script async src="https://www.googletagmanager.com/gtag/js?id=AW-123456"></script>

<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());
 gtag('config', 'AW-123456', { ' allow_enhanced_conversions' : true } ) ;
</script>


{% if first_time_accessed %}
<script>
  gtag('event', 'conversion', {
     'send_to': 'AW-123456/es3dg6fjh78tr',
    'value': {{ checkout.total_price  | divided_by: 100.0 }},
    'currency': '{{ currency }}',
    'transaction_id': '{{ order_number }}',
  });

gtag('set', 'user_data', {
    "email": "{{ checkout.customer.email }}",
    "phone_number": "{{ checkout.customer.phone }}",
    "address": {
        "first_name": "{{ checkout.customer.first_name }}",
        "last_name": "{{ checkout.customer.last_name }}",
        ,
        "street": "{{ shipping_address.address1 }}",
        "city": "{{ shipping_address.city }}",
        "region": "{{ shipping_address.province  }}",
        "postal_code": "{{ shipping_address.zip }}",
        "country": "{{ shipping_address.country }} "
    }

});

</script>
{% endif %}

To debug, enter the conversion label for the "Network" search bar and spot a variable named "em:"