Last active
May 2, 2022 17:20
-
-
Save michelarteta/641061ed8543e58cb3d0e165045baa96 to your computer and use it in GitHub Desktop.
GTM Universal Tag
This file contains hidden or 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
<script> | |
var g_account = 'AW-0000000'; | |
var send_to = 'AW-00000000/egZ000000000000000'; | |
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> | |
<script async src="https://www.googletagmanager.com/gtag/js?id="+g_account></script> | |
<script> | |
window.dataLayer = window.dataLayer || []; | |
function gtag(){dataLayer.push(arguments);} | |
gtag('js', new Date()); | |
gtag('config', g_account, {'allow_enhanced_conversions': true}); | |
</script> | |
{% if first_time_accessed %} | |
<script> | |
gtag('event', 'conversion', { | |
'send_to': send_to, | |
'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