Setting up Google Adwords Enhanced Conversions in Shopify

Code and setup instructions for installing Enhanced Google Conversions in Shopify

By Rob Johnson

Mon May 02 2022

Google Adwords Enhanced Conversions provide more data to Google that help drive their algorithms to better optimize when and how your product listings and campaigns are shown to potential customers.

Below are instructions on the Enhanced Conversion script that is run after the checkout has been completed.

Create a new Conversion in your Google Adwords account with Enhanced Conversions turned on

The below image outlines how you want to setup a Coversion with Enhanced Conversions tracking.

You'll want to make sure you add the tracking via Global site tag which will allow you implement the tag on the back-end instead of Google Tag Manager which can be blocked with Ad-Blockers.

Setup for a Google Enhanced Conversion

Download Google Tag Assistant Chrome browser extension

To help confirm that your tags are properly setup and verify the conversion labels are correct download Google Chrome extension Tag Assistant Legacy (by Google). You will use it to verify you have the correct tags firing on the correct pages.

Shopify Config for Google Enhanced Conversions

  1. Setup a conversion in your AdWords account
  2. Verify that you have the correct conversion label
  3. Verify that you have the correct Google Ads account number
  4. Go to Shopify Admin > Settings > Checkout
  5. Paste the below code in the Order status page section. (Make sure to replace ACCOUNT_ID_HERE and CONVERSION_LABEL_HERE with your Google Adwords account and conversion label.)
<script>
var enhanced_conversion_data = {
"first_name": "{{ checkout.billing_address.first_name }}",
"last_name": "{{ checkout.billing_address.last_name }}",
"home_address": {
"street": "{{ checkout.billing_address.street }}",
"city": "{{ checkout.billing_address.city }}",
"region": "{{ checkout.billing_address.province }}",
"postal_code": "{{ checkout.billing_address.zip }}",
"country": "{{ checkout.billing_address.country_code }}"
}
}
if("{{ checkout.email }}"){
enhanced_conversion_data.email = "{{ checkout.email }}";
}
if("{{ checkout.billing_address.phone }}"){
enhanced_conversion_data.phone_number = "{{ checkout.billing_address.phone }}";
}
</script>

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

gtag('config', 'AW-ACCOUNT_ID_HERE', {'allow_enhanced_conversions': true});
</script>

{% if first_time_accessed %}
<script>
gtag('event', 'conversion', {
// add your account ID and Conversion label here
'send_to': 'AW-ACCOUNT_ID_HERE/CONVERSION_LABEL_HERE',
'value': {{ checkout.total_price | divided_by: 100.0 }},
'currency': '{{ currency }}',
'transaction_id': '{{ order_number }}',
});
</script>
{% endif %}

See also the Google Support developer documentation


# commerce 9 # seo 4 # tools 5 # sql 3 # javascript 10 # projects 4 # css 2 # git 2 # php 3 # analytics 4 # monitoring 2 # api 3 # shopify 4 # python 2 # aws 2