Hi,
i am having a problem to get the google ads tracking to work.
We are actually not using the google shopping app, because we need a more difficult mapping of fields. So we cannot use the feature of that app to setup the tracking scripts automaticly, wich is recommended in multiple other threads around this topic.
I followed the official shopify guides and added the following code snipped to our theme.liquid <head> section:
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-*******1234*********"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'AW-*****1234*****'); </script>
Then in settings > checkout > additional scripts i added:
{% if first_time_accessed %} <script> gtag('event', 'conversion', { 'send_to': 'AW-******12234**********', 'value': {{ checkout.total_price | money_without_currency }}, 'currency': '{{ shop.currency }}', 'transaction_id': '{{ order_number }}' }); </script> {% endif %}
This is actually not working at all. There has been lots of conversions, but the conversion action within google ads has not been verified. All the setup was made 2 weeks ago, so it's not a delay of google ads.
What am i doing wrong?
Im JS developer myself and feel kinda stupid, because after reading the shopify docs several times, i cannot find anything wrong.
Regards
Stefan
Solved! Go to the solution
Hi Stefan
Why not import a Google Analytics goal based on someone making a purchase into Google ads? If you do that, then you can track everything you want. Just make sure you import the transaction goal type and you are good to go. Hope you found this helpful, if so please click "like" below to let me know.
You should install both global tag and event in the additional section.
It will then work.
I recognized that too yesterday and added it to the section. Im just wondering why there is no hint about that in the official shopify tutorial.
But there was one more issue, that is probably country specific and even not documented.
In the most european countries the price values are displayed with a comma separator such as 9,99 EUR. So the value returned from
{{ checkout.total_price | money_without_currency }},
is not a valid number and caused a script error.
I am not sure if google accepts the value as string, but for now i changed it to:
'value': '{{ checkout.total_price | money_without_currency }}',
Those changes has been done about 10h ago and still there is no active tracking status in google ads.
Any idea what else could be wrong?
This is an accepted solution.
the correct code is
checkout.total_price | money_without_currency | remove:'.' | replace: ',', '.'
You should submit it as an integer, not a string.
So remove the double or single quotes.
It should look like this:
{% if first_time_accessed %} <script> gtag('event', 'conversion', { 'send_to': 'xx-123456789123/lkadsjKDweLK45W', 'value': {{ checkout.total_price | money_without_currency | remove:'.' | replace: ',', '.' }}, 'currency': '{{ shop.currency }}', 'transaction_id': '{{ order.order_number }}' }); </script> {% endif %}
User | Count |
---|---|
8 | |
6 | |
6 | |
5 | |
4 |