Google Ads Conversion Tracking - Final Solution
Summary
Here’s what we did to address everything in Task 1:
- Made
valueparameterorder.subtotal_price | money_without_currency | remove:','which removed currency symbol and commas.
👉 Subtask 1 Solution
- Set
transaction_idparameter toorder.order_number.
👉 Subtask 2 Solution
- Ensured order subtotals over $999.99 are captured by removing commas in Subtask 1.
👉 Subtask 3 Solution
- Prevented collection of duplicate orders by setting
transaction_idto the unique valueorder.order_number.
👉 Subtask 4 Solution
- Encapsulating the conversion script with
{% if first_time_accessed %} {% endif %}to ensure the script only executes once.
👉 Subtask 5 Solution
Putting it all together, the final updated code looks like this:
<!-- Global site tag (gtag.js) - Google Ads: 123456789 -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-123456789"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-123456789');
</script>
{% if first_time_accessed %}
<!-- Event snippet for Test conversion page -->
<script>
gtag('event', 'conversion', {
'send_to': 'AW-123456789/AbC-D_efG-h12_34-567',
'value': {{ order.subtotal_price | money_without_currency | remove:',' }},
'currency': '{{ checkout.currency }}',
'transaction_id': '{{ order.order_number }}'
});
</script>
{% endif %}
For reference, included below is the original Task 1 information:
The client has just created a new Google Ads account, and their Ecommerce platform is Shopify. Below is a broken Google Ads Conversion Tracking Tag. The value parameter should be Order Subtotal (which should not include a currency symbol or any commas), and we will also be including a new parameter, transaction_id which will be the Order Number. Revenue is only showing up for orders less than $1,000, and orders are being duplicated. Please help! Shopify has a piece of code that only allows a script to fire the first time a page is accessed, can you
add that as well?Click to expand
Task 1
Prompt
Bonus
Code
Click to view the code
<!-- Global site tag (gtag.js) - Google Ads: 123456789 -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-123456789"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-123456789');
</script>
<!-- Event snippet for Test conversion page -->
<script>
gtag('event', 'conversion', {
'send_to': 'AW-123456789/AbC-D_efG-h12_34-567',
'value': {{ subtotal_price | money_without_currency }},
'currency': '{{ currency }}',
'transaction_id': '{{ transaction_id }}'
});
</script>
👉 Jump to Task 2