• Home
  • Blog Categories
    • AdWords
    • Facebook
    • Amazon
    • eCommerce
    • Lead Generation
    • Google Exams
  • Blog Archive

PPC Wins

Tips & strategies for getting the most from your PPC campaigns

How to setup AdWords Conversion Tracking for Shopify

November 2, 2016 By John King 34 Comments

Its very useful, when you’re running AdWords campaigns, to correctly track conversions (conversions in eCommerce generally = sales).

If you don’t do this, its hard to optimize your campaigns and make more $$$.

In this post I’m going to show you how to setup AdWords conversion tracking for Shopify.

CRUCIALLY, I’m going to show you how to add code that avoids tracking duplications. That is to say, it will prevent a sale for appearing as 2 or more conversions, when there was only one! (yes, this happens sometimes).

To check if you’ve been getting duplicate conversions in AdWords, go to Tools in the top bar, then conversions. Then from the conversions page, choose webpages from the left side:

adwords-conversions-webpages

Set the time period you’re look at to All Time, or at least 30+ days. This should give us enough conversion data to work with. Then sort the list of results in descending order by clicking All Conversions.

If any of the pages have more than one conversion (such as below), you know you’ve been hit with duplicate Shopify conversions:

adwords-duplicate-conversions

In order to setup AdWords conversion tracking correctly, this is the process we are going to follow:

  1. Get conversion code from AdWords
  2. Edit the code, so that we add in custom code for Shopify
  3. Paste the edited code into a box in your Shopify admin panel

1/ Get conversion code from AdWords

In your AdWords account, choose Tools and then Conversions

adwords-conversion-tracking-link

And then you want to choose + Conversion

setup-new-conversion

 

Then choose Website Conversion

 

adwords-conversions

Then choose the following settings:

  • Name: Shopify Sale
  • Value: Each conversion has a different value. If there’s no value, use $1
  • Count: Every Conversion
  • Conversion Window: 30-day conversion window
  • Category: Purchase/Sale
  • Include in “Conversions”: Yes
  • Attribution model: Use “Last Click” model

choose-conv-settings

 

Then choose Save and continue

At which point you will get the snippet of code that you need:

conv-code-page

The code will look like this:

<!-- Google Code for Shopify Sale Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = your-id;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "your-label";
var google_conversion_value = 1.00;
var google_conversion_currency = "USD";
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/your-id/?value=1.00&amp;currency_code=USD&amp;label=your-label&amp;guid=ON&amp;script=0"/>
</div>
</noscript>


Now we want to modify it with the following changes:

We want to change the line:

var google_conversion_value = 1.00;


to

if ({{ subtotal_price }}) { var google_conversion_value = {{ subtotal_price | money_without_currency | remove: ',' }}; }

Lastly, you’ll want to edit the part of the noscript tag that contains the value. Change

value=1.00

to

value={{ subtotal_price | money_without_currency | remove: ',' }}

 

Making the above code look like this:

<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = your-id;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "your-label";
if ({{ subtotal_price }}) { var google_conversion_value = {{ subtotal_price | money_without_currency | remove: ',' }}; }
var google_conversion_currency = "USD";
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/your-id/?value={{ subtotal_price | money_without_currency | remove: ',' }}&amp;currency_code=USD&amp;oid={{order.order_number}}&amp;label=your-label&amp;guid=ON&amp;script=0"/>
</div>
</noscript>

Next, we want to add some code to track order IDs. This is the bit that will prevent us registering duplicate conversions in AdWords. See the Google article for extended details on how it works.

We will add the following line:

if ({{ order.order_number }}) { var google_conversion_order_id = "{{ order.order_number }}"; }

Essentially the code says; check if the page returns an order number, and if so, pass it to the variable.

You may want to check your order number setup in Shopify, because if you edited it, and want it to match up, you’ll need to add an extra prefix. I don’t think you need it to match up 100% though. All this functions serves to do is ensure the same order number can’t be counted twice.

Then we want to add the corresponding noscript tag:

&amp;oid={{ order.order_number }}

Making the code look like this:

<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = your-id;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "your-label";
if ({{ subtotal_price }}) { var google_conversion_value = {{ subtotal_price | money_without_currency | remove: ',' }}; }
if ({{ order.order_number }}) { var google_conversion_order_id = "{{ order.order_number }}"; }
var google_conversion_currency = "USD";
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/your-id/?value={{ subtotal_price | money_without_currency | remove: ',' }}&amp;currency_code=USD&amp;oid={{ order.order_number }}&amp;label=your-label&amp;guid=ON&amp;script=0"/>
</div>
</noscript>

 

At which point we’re nearly there.

Finally, we have the option to add some further code.

Shopify have a snippet of liquid code called first_time_accessed (more info on it here). Code placed within this statement *should* only be displayed once.

Since testing it, I’ve found its not 100% reliable. Hence adding the above order ID code.

But it’s better than nothing for the other codes in your checkout code. Ones that don’t have an order ID parameter that can be added (Bing comes to mind).

All you have to do is surround your conversion code with the statement:
{% if first_time_accessed %}

and then close it with:
{% endif %}

All this code goes in the Additional Scrips box in your Shopify dashboard. This section can be located by going to Settings -> Checkout. Scroll down until you find this box:

shopify-additional-scripts-box

If any of the above isn’t clear, leave me a comment, and I’ll clarify + improve it.

Filed Under: AdWords

Comments

  1. Nhân Tov says

    July 31, 2017 at 8:46 am

    So my conversion code will look like this? Is that true? I have install the code without the line “{% if first_time_accessed %}” and “{% endif %}” and Google tag assistant said that “No HTTP response” and “Conversion value not set”. Thank you

    {% if first_time_accessed %}

    /* */

    //www.googleadservices.com/pagead/conversion.js

    {% endif %}

    Reply
    • John King says

      July 31, 2017 at 3:49 pm

      Yeah, that code isn’t correct.
      Needs the variables for things like price and product ID.

      Reply
      • Nhân Tov says

        July 31, 2017 at 4:40 pm

        I don’t know why my comment was be shorten. But here is the full code I have installed in the website. I don’t know why it didnt work.
        Sorry that I’m so weak in coding. Thanks for your reply.

        Reply
      • Nhân Tov says

        July 31, 2017 at 4:41 pm

        https://uploads.disquscdn.com/images/4dc45753f0e6862afd7359e3773af9a99ca4647295dba6e6b6ca48eac7c14f76.jpg

        Reply
  2. Sang Do says

    July 20, 2017 at 5:30 am

    Hi John, the Google Tag was changed. How do I apply your tutorial?

    goog_snippet_vars = function() {
    var w = window;
    w.google_conversion_id = 856476547;
    w.google_conversion_label = “EBy_CPuPonMQg5ezmAM”;
    w.google_conversion_value = 1.00;
    w.google_conversion_currency = “USD”;
    w.google_remarketing_only = false;
    }

    Reply
    • John King says

      July 22, 2017 at 4:45 pm

      Hi Sang.

      That code looks like conversion tracking code – rather than retargeting code.
      The giveaway is that w.google_remarketing_only = false

      For the remarketing code, that value will be set to true.

      Try again at finding the remarketing code.

      AdWords are running a Beta of the new interface. And whilst its possible to find the correct code in the Beta, it won’t match the screens in my video above. If needs be, switch back to the old interface temporarily.

      Reply
      • Sang Do says

        July 22, 2017 at 6:58 pm

        Great, John.

        I found the tag. Really hate new beta interface.

        Reply
        • John King says

          July 22, 2017 at 7:15 pm

          Agree – it’ll take a little while to get used to it.

          Also worth noting, its actually missing a few features, that you have to go back to the old version to get access to (for now).

          Reply
  3. msutyler says

    May 4, 2017 at 9:42 pm

    How can we track conversions from paypal? This seems to be a big issue. When paypal purchases are absent, the stats are grossly skewed.

    Reply
    • John King says

      May 4, 2017 at 11:10 pm

      Hi Tyler.

      Good question. When customers pay with Paypal on Shopify, when the transaction is successful, they get redirected back to the Shopify order confirmation page. This is where we have our checkout code, including AdWords conversion tracking code. Thus, if the customer pays via the Shopify payment gateway, or via Paypal, the same checkout code tracks both.

      A link with a bit more info:
      https://ecommerce.shopify.com/c/payments-shipping-fulfilment/t/paypal-auto-return-for-website-payments-149022

      Reply
      • msutyler says

        May 4, 2017 at 11:14 pm

        Strange. I still find that I miss some paypal conversions. Maybe because the user is never routed back to the site. Is this a setting within Paypal?

        Reply
        • John King says

          May 4, 2017 at 11:20 pm

          There is a setting within PayPal, but it isn’t used for Shopify. Shopify’s integration uses its own settings, with an automatic redirect.

          If I think of anything that could be causing an issue, I’ll let you know.

          Reply
          • msutyler says

            May 4, 2017 at 11:30 pm

            Yeah. Maybe it’s not a Paypal thing. But I do know for a fact that not all conversions are being counted. In both analytics and adwords.

          • John King says

            May 4, 2017 at 11:33 pm

            So with the AdWords conversion tracking code, it’ll only track conversions where the customer has an AdWords ad cookie stored in their browser. If they find the site via organic search, a link on social media, or type it in directly, it won’t track that conversion.

            Analytics should have data for most, if not all conversions. Irregardless of what the source was.

  4. Shilpi Agarwal says

    March 16, 2017 at 8:19 pm

    Hi Josh,
    If I setup a ‘Placed an Order’ Goal in Google Analytics and link that in Google Adwords, with Dynamic Conversion value on (meaning the value of the conversion will be based on the transaction amount that Google Adwords will get from Google Analytics), do I still need to place a conversion tracking code on my Shopify Checkout page?

    Reply
    • John King says

      May 4, 2017 at 6:25 pm

      Hi Sheila

      Who’s Josh? ;)

      No, you don’t need to place AdWords conversion tracking code in your Shopify checkout page if you are tracking conversions separately using Google Analytics.

      Reply
  5. Alexandre Billaut says

    February 5, 2017 at 5:41 pm

    Ho Josh,

    > Jose : If you chose one conversion only, then it won’t count your recurrent customers.

    > Josh: Could you propose the good code at the end, with all the modifications? We would only have to copy/paste then and change the conversion ID and label ID? W

    Reply
    • John King says

      May 4, 2017 at 6:26 pm

      The last set of code is essentially there for people who want to copy and paste.

      Reply
  6. Jose A Apezteguia says

    January 19, 2017 at 4:09 am

    Why choose Every Conversions? Its not better have accurate data with only 1 conversion ? Thanks

    Reply
    • John King says

      May 4, 2017 at 6:27 pm

      You can, however, if people make multiple purchases, they would only track as one.

      Reply
  7. msutyler says

    January 14, 2017 at 9:08 am

    Hey John,

    I’m getting a ‘tag inactive’ error when looking on my code. What’s weird is that last month it was working fine? I haven’t changed anything?

    Reply
    • John King says

      January 14, 2017 at 5:00 pm

      Yeah, that’s weird, the tag shouldn’t be inactive. Use Google Chrome tag assistant to make sure the remarketing code is on your websites pages.

      Reply
  8. Faiysal Kothiwala says

    January 14, 2017 at 8:16 am

    {% if first_time_accessed %} & {% endif %} where do i place these? like before and after the whole code?

    Reply
    • John King says

      January 14, 2017 at 4:59 pm

      That’s correct!

      Reply
  9. Rick Frankly Jr. says

    December 10, 2016 at 6:36 pm

    Hey John,

    Great post. Its crazy how little information is available for integrating Google tags with Shopify. This is a big help.

    One thing that I found a bit confusing, you say to make 2 modifications, but looking at your final code there is a 3rd…

    if ({{ order.order_number }}) {var google_conversion_order_id = “{{ order.order_number }}”;}

    May want to add this, not sure if its mission critical but I almost missed it.

    Thanks for the great info!

    Reply
    • John King says

      December 12, 2016 at 2:33 pm

      Hey Rick! Good spot.

      For a while I was using that line to help prevent duplicate conversions. But actually the implementation of that can be more complex than desired (for example if someone uses an order number prefix).

      The first_time_accessed script should be enough, so I’ve taken that line out to avoid complications.

      Reply
  10. Dante says

    November 29, 2016 at 9:15 pm

    I think you may have left out the very last part as to where to paste the code snippet? I believe it would go at Settings > Shipping > “Additional Scripts” Box ?

    Reply
    • John King says

      December 3, 2016 at 7:14 am

      Yes! Had missed that out. Yes, go to Settings > Checkout > Additional Scripts.
      Thanks for pointing that out Dante.

      Reply
  11. Patrick D. Porter says

    November 10, 2016 at 8:26 pm

    Hi John,

    Awesome post! First one I’ve found that includes the “order_number” variable in it… a few questions for you:

    1) I noticed in the Shopify API documentation there is an “order_number” and also “order_id”. Do you know if both work, or what the difference is? https://help.shopify.com/api/reference/order#index

    2) Why does the order_number need to be in double quotes here?

    if ({{ order.order_number }}) {var google_conversion_order_id = “{{ order.order_number }}”;}

    3) Did you prepend order_number with “order.” because of your website specifically? How do I know if I need to do this?

    Thanks,

    Patrick

    Reply
    • John King says

      November 10, 2016 at 8:38 pm

      Hi Patrick,

      Thanks for the message.

      1) Order ID doesn’t seem to exist in the liquid variables options. You’ve linked to the API which we’re not using.

      2) That parameter takes a string value, and strings need to be surrounded by quotation marks.

      3) See here:
      https://help.shopify.com/themes/liquid/objects/order

      We have to prepend with order.

      Hope that helps.

      Reply
      • Patrick D. Porter says

        November 17, 2016 at 8:05 pm

        Thank you, John – very helpful. A couple follow up questions

        1) What is the purpose of the “remove: ‘,'” section?
        2) So if I used a Shopify theme to build my site, I’ll have to use the “order.order_number” parameter?

        Cheers,

        Patrick

        Reply
        • John King says

          November 20, 2016 at 5:05 am

          1) For numbers that are over 999, Shopify adds a comma. This removes it, so that it can be parsed correctly as a number rather than a string.
          2) You don’t have to, but is an option.

          Reply
          • Patrick D. Porter says

            November 22, 2016 at 7:57 am

            Thank you John, this worked great. Really appreciate you taking the time to post!

Leave a Reply Cancel reply

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

Popular Posts

First Time Here?

Hey and welcome to the site.

PPC Wins is a site dedicated to sharing with you useful tips and advice for getting the most out of PPC campaigns.

If there is a topic you would like to see covered please get in contact.

Categories

  • AdWords
  • Amazon
  • eCommerce
  • Facebook
  • Google Analytics
  • Google Exams
  • Lead Generation
  • Uncategorized
google-adwords-certified-partner2
BingAds_Accredited_Badge (1)

Copyright © 2022 ppcwins.com