Created
July 29, 2022 00:25
-
-
Save hezninja/6ce91951e498edc9c7ab3ff89a2ce3fe to your computer and use it in GitHub Desktop.
Enhanced Conversions for Shopify
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Global site tag (gtag.js) --> | |
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-XXXXXXXXX"></script> | |
<script> | |
window.dataLayer = window.dataLayer || []; | |
function gtag(){dataLayer.push(arguments);} | |
gtag('js', new Date()); | |
gtag('config', 'AW-XXXXXXXXX', {'allow_enhanced_conversions': true}); | |
</script> | |
<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> | |
<!-- Event snippet for Purchase AU conversion page --> | |
{% if first_time_accessed %} | |
<script> | |
gtag('event', 'conversion', { | |
'send_to': 'AW-XXXXXXXXX/XXXXXXXXXXXXXXXXXXXX', | |
'value': {{ checkout.total_price | divided_by: 100.0 }}, | |
'currency': '{{ currency }}', | |
'transaction_id': '{{ order_number }}' | |
}); | |
</script> | |
{% endif %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment