Enhanced Google Ads Conversion Script for Shopify

May 22, 2021

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  "manual" tagging option at Google Ads enhanced conversion settings  also accept Google's terms and conditions.

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

Along with above be sure to place transaction and base script with enhanced ecommerce enabled.

<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 }}',
  });
</script>
{% endif %}

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