Google Ads Conversion Tracking - Final Solution

Summary


Here’s what we did to address everything in Task 1:

  1. Made value parameter order.subtotal_price | money_without_currency | remove:',' which removed currency symbol and commas.

👉 Subtask 1 Solution

  1. Set transaction_id parameter to order.order_number.

👉 Subtask 2 Solution

  1. Ensured order subtotals over $999.99 are captured by removing commas in Subtask 1.

👉 Subtask 3 Solution

  1. Prevented collection of duplicate orders by setting transaction_id to the unique value order.order_number.

👉 Subtask 4 Solution

  1. 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:

Click to expand

Task 1


Prompt

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!

Bonus

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?

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> 

NEXT
👉 Jump to Task 2

Previous