增强型转化客户数据代码
<script>
gtag('set', 'user_data', {
"email": '{{ customer.email }}',
"phone_number": '{{ billing_address.phone }}',
"address": {
"first_name": '{{ billing_address.first_name }}',
"last_name": '{{ billing_address.last_name }}',
"street": '{{ billing_address.street }}',
"city": '{{ billing_address.city }}',
"region": '{{ billing_address.province }}',
"postal_code": '{{ billing_address.zip }}',
"country": '{{ billing_address.country_code }}'
}
});
</script>
配置转化页Google代码
将“{'allow_enhanced_conversions': true}”添加到Google代码中可在所有网页中触发的“config”行。
gtag('config', 'TAG_ID', {'allow_enhanced_conversions':true});
添加前:Google 代码示例(当前代码):
<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'TAG_ID');
</script>
添加后:
<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config','TAG_ID', {'allow_enhanced_conversions':true});
</script>
在Shopify Admin > Settings > Checkout > Additional scripts加入代码
<script async src="https://www.googletagmanager.com/gtag/js?id=TAG_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config','TAG_ID', {'allow_enhanced_conversions':true});
</script>
{% if first_time_accessed %}
<script>
gtag('event', 'conversion', {
'send_to': 'TAG_ID/CONV_ID',
'value': {{ checkout.total_price | divided_by: 100.0 }},
'currency': '{{ order.currency }}',
'transaction_id': '{{ order_name }}'
});
gtag('set', 'user_data', {
"email": '{{ customer.email }}',
"phone_number": '{{ billing_address.phone }}',
"address": {
"first_name": '{{ billing_address.first_name }}',
"last_name": '{{ billing_address.last_name }}',
"street": '{{ billing_address.street }}',
"city": '{{ billing_address.city }}',
"region": '{{ billing_address.province }}',
"postal_code": '{{ billing_address.zip }}',
"country": '{{ billing_address.country_code }}'
}
});
</script>
{% endif %}
