Shopify - pay only $1 /pm for 3 months   GO!
Detect Shopify Theme

Or go to our Shopify Theme Detector directly

How to Add Google Ads Tracking to Shopify

Last modified: December 3, 2021

FAQ
How to Add Google Ads Tracking to Shopify
Shopify Trial

If you advertise on Google, then you will want to make sure that you’re getting the most money for your investment. This means that you will want to add Google Ads tracking to your Shopify store. This is an advanced lesson and you should have at least some knowledge of HTML and editing code on Shopify.

Step 1 – Create a Conversion Action in Google Ads

The first step is to create a conversion action within the Google Ads framework. There are many different kinds of conversion actions, with tracking purchases being the most common. This one will enable you to see how effective your ads are at generating sales on your store.

To track purchases, go to the Google Ads and then create the conversion action and set the category to Purchase/Sale and then value to ‘Use different values for each conversion.’

When you’re done creating your conversion actions, click ‘Create and Continue’.

Step 2 – Install Global Site Tag

After you’ve done this, you can install the global site tag on your Shopify theme code.

To do this you need to get the generated code that is dependent on several factors. You can get this from your Google ads account.

Step 3 – Shopify Log In

Now you need to go to your Shopify website and log into the store’s backend.

Step 4 – Online Store

Now click on the ‘Online Store’ option and then find the theme that you’re using in the ‘Themes’ section. Click on the ‘Actions’ and then ‘Edit code’. Find and open your theme.liquid file.

Step 5 – Install Global Site Tag

If this is the first time that you’ve added the global site tag to your website, then ensure that you paste and copy the global site tag somewhere within the header tags. This will apply the tag and the tracking to every page on your website. If you’re editing a code, then find the old code and replace it as Google suggests.

Step 6 – Save

Once complete, save your changes.

Step 7 – Install Event Snippet

Now you need to add the event snippet to your checkout page. To do this you need to copy the event snippet code from Google Ads page under the ‘Event Snippet’ section and select the option for ‘Page Load’.

Within your Shopify store go to the ‘Settings’ and then ‘Checkout’ option. In the ‘Order Processing’ section find the additional scripts text box and paste the event snippet from Google. You should also add the global site tag above the event snippet.

You also need to add these two lines of code above and below extra snippets.

On the line before the snippet, paste {% if first_time_accessed %}.
On the line after the snippet, paste {% endif %}.

The default currency used by Google is USD. If you need to replace this, you can use this code with some customization for your website’s need.

{% if first_time_accessed %}
<!-- Event snippet for Test conversion page -->
<script>
gtag('event', 'conversion', {
'send_to': '1234567',
'value': {{ checkout.subtotal_price | divided_by: 100.0 }},
'currency': '{{ currency }}',
'transaction_id': '{{ order_number }}',
});
</script>
{% endif %}

The above code will track the conversion value of the purchases without taxes. If you would like with tax, then you can use this code instead:

{% if first_time_accessed %}
<!-- Event snippet for Test conversion page -->
<script>
gtag('event', 'conversion', {
'send_to': '1234567',
'value': {{ checkout.total_price | divided_by: 100.0 }},
'currency': '{{ currency }}',
'transaction_id': '{{ order_number }}',
});
</script>
{% endif %}

Once you’ve completed the process, you can click on the ‘Save’.

Final Word: How to Add Google Ads Tracking to Shopify

The above helps you to set up Google Ads tracking on your Shopify store. This can help you analyse where your best sales are coming from and where to assign your budget. It is a hard lesson to learn, and therefore, should only be tried by those confident in coding and Google. Alternatively, you can use this app.

Got Something To Say?

Your email address will not be published. Required fields are marked *