Shopify Where to Add Google Conversion Tracking

How to Setup Google Ads Conversion Tracking in Shopify

After completing over one hundred audits of Google Ads (AdWords) accounts for Shopify businesses, I am dumbfounded at the number of accounts that don't have accurate conversion tracking setup. Agencies and store owners will spend tens of thousands each month with no idea what, if any part of the campaigns, generate sales. Other businesses may track a sale as one conversion, but they have no revenue data—the sale of a $10 product looks the same as a $1000 product.

Yet another mistake we see every month in Shopify is the failure to consider multiple currencies due to Shopify Markets or the multi-currency feature. Users can shop in their local currency. A 20,000 South Korean won purchase equal to US$17 ends up looking might fine when Google receives it as US$20,000.

The most common Google Ads tracking mistake we see in Shopify is someone installs some version of a tracking code. When it's time to setup a shopping feed in Shopify, they need a simple solution given their lack of technical skills so they move on to install Shopify's Google channel. The channel installs its own conversion codes. The result is usually a doubling-up of purchase data to bloat the account manager's ego that they are raking in coin. Here's an example of this from an audit we did two days ago:

Google Ads Conversion Tracking Not Working in Shopify

You have to know what searches, ads, products, and audiences succeed or fail at bringing in your ROAS goal. That requires accurate tracking.

This tutorial covers how to create the most perfect Google Ads conversion code you can with the latest features of cart data (basket data) and enhanced conversions. These two features result in more purchase data and reported conversions that drives profit. You'll get the exact solution that we use on client stores to help Shopify stores grow through Google Ads.

Previously known as Google AdWords, Google Ads has three ways to setup conversion tracking in Shopify.

Option 1: If you accurately track sales in Google Analytics, the quickest solution is to import your transactions as a conversion goal. See the steps to import transactions from analytics to Google Ads. We never use this method.

Option 2: Google channel in Shopify. This option is better than the first because it is more foolproof. With that said, I did say people still stuff this by doubling up with other purchase conversion events. You get a variety of additional conversions automatically created like "Add to Cart" and "Begin Checkout" that can be used to leverage bidding algorithms. The data doesn't distort reporting because the events are excluded from the "Conversions" reporting column and associated metrics. The downside of this option is it makes no use of cart data or enhanced conversions that result in more data and more conversions. You'll see what you're missing out on soon.

Google channel in Shopify with various conversions

Option 3: Manual implementation with full features covered in this guide. The tutorial covers why you need to edit the existing Google Ads conversion code and how to do it for the best data using the latest features for ecommerce. We use this solution to help Shopify stores grow.

I also like this option over importing a purchase conversion through Google Analytics because my testing has repeatedly shown sales through Google Ads are lost to the (direct)/(none) traffic source in Google Analytics due to cross-domain tracking limitations or other marketing channels depending on your attribution settings. This means your advertising would lack the proper attribution it deserves for generating sales. For one of my Google Ads clients I was able to attribute more than double the sales of Google Ads with the conversion tracking code compared to analytics. That level of data accuracy can be the difference between the death of an ecommerce business and it thriving.

You will learn how to setup Shopify with gtag.js tracking for Google Ads. One benefit of gtag.js is its simplicity. The second benefit is its increased accuracy over the older ga() functions to combat intelligent tracking prevention in Safari. Here we go.

1. Create your conversion in Google Ads

1. In your Google Ads account from the top-right, click the spanner icon. Under the "Measurement" column, go to "Conversions":

Google AdWords conversion tab

2. Create a new conversion. Click "Website".

Use the following settings for your conversion:

  • Name: The name can be anything. I recommend you make it "Sales"
  • Category: "Purchase/Sale"
  • Value: "Use different values for each conversion" and select the currency used in your Shopify store. It is okay if this currency is different to your ad account as Google will do the currency conversion. You could enter your average order value (AOV) taken from Google Analytics as the default value. Your average order value can be gather from the "Conversions" > "Ecommerce" > "Overview" section. However, as you'll see, this value is never empty because we'll replace this with a liquid variable that contains the order amount in dollars.
  • Count: "Every".
  • Conversion windows: "30 days". If your products cost more than $200 or you know customers take weeks to research a product before buying, extend the value to "90 days".
  • View-through conversion window: "1 day".
  • Include in "Conversions": Tick this option. The setting lets you decide if these conversions should be included in your "Conversions" and "Conversion value" columns
  • Attribution: "Linear". Let's say a person clicks one ad then returns to Google for another search. They then click another ad and buy. The first ad should receive recognition for the sale so you can more accurately optimise campaigns with this data. The linear model means each ad and search term will get 0.5 of a conversion. If you used the last-click option, the first ad would get 0 and the second ad would get 1 conversion. Never use the last-click option because it ignores the effect of upper funnel ads. We will geek out on the various models soon. Linear is a good default.

Your event tag options will look something like:

Google Ads conversion options for Shopify

3. Save to finish creating your conversion code in Google Ads. Select the option to "Install the tag yourself".

4. Click "The global site tag isn't installed on all your HTML pages" option for the global site tag.

5. Click the "Page load" option for the event tag.

We will need to modify the event tag then add the global tag and the modified event tag to your Shopify store to complete setup. But first, I want to educate you about attribution.

Picking the Perfect Attribution Model

If someone clicked on you Google Shopping ad, looked at a product but didn't buy, then later returned to the site through a branded search ad before purchasing, would you attribute 100% of that purchase to the branded keyword? Unfortunately, most stores use an attribution model that ignores earlier interactions.

Attribution modelling in Google Ads and Analytics is a set of rules that determines how each transaction or conversion is credited. Within Analytics, the last-click model (most commonly used by novices to measure sales and goal completions) attributes 100% of the sale to the last action associated with how the user accessed the site such as organic, paid search, or other channel. The first click does the opposite which grants 100% to the first interaction. Realistically, ecommerce stores often see a journey with a variety of interactions before a user becomes a customer. This is why you must consider what model is best.

There are a number of attribution models available to use.

Linear: I recommend this model when you first set up your attribution modelling. It attributes the sale evenly across all touchpoints or interactions the customer has had throughout their buying cycle. This will help you understand how each platform in your multi-channel marketing strategy has benefited your revenue. For example, if the customer originally came to the site through a Facebook product ad, came back again through Google Shopping, then came back via a search ad and eventually came to the site organically, the linear attribution model will award 25% of the sale to each channel.

First click: This model awards 100% of the conversion or sale to the first interaction or touch-point the customer had. It is useful to identify how your customers are finding you, but the model disregards later touch-points the visitor has with your business. You will not know what led to the sale when there is more than one click.

Last click: The opposite of first click attribution—it attributes 100% of the sale to the last interaction had by the customer. It is badly favoured by many online retailers. Given businesses get customers on many marketing platforms, it's vital to know the influence each platform has had on the sale. Last click doesn't give you this information.

Position-based: This is a mixture of all of the above but with the majority of the conversion (about 80%) split between the first and last click. The remaining 20% is attributed to the middle of the funnel. This can work for many ecommerce retailers. Those with more expensive items may find the middle touch-points are not attributed enough as larger items are usually a longer consideration process for the customer.

Time decay: The most complex model of all of them. Time decay puts the most emphasis on the last click, however it attributes a percentage to other touch-points in the journey. The touch-points furthest away from the sale get the least attribution, building up to the most attribution at the final touch-point. This model is worth considering if your customers take a longish time-to-purchase.

Data-driven: An automated attribution method that uses real historical data. Google will look at many data points to build your own attribution model. You may not have this model available as it initially requires 600 conversions through a single conversion action over 30 days. Use it when you meet the requirements. You can learn more about data-driven attribution.

For further help with selecting the best attribution model when your campaigns progress, refer to the Model Comparison Tool. You will be able to test the affect different models have on your data.

2. Enable Enhanced Conversions

Enhanced Conversions is a new Google Ads tracking feature that improves the accuracy of conversions through hashed first-party data. The hashed data is matched with signed-in Google accounts for better attribution. This tutorial matches customer data from their Shopify purchase to their Google Ads account.

1. When viewing details of the conversion, tick to enable enhanced conversions:

Enhanced Conversions

2. Select "Global site tag or Google Tag Manager".

3. In the Shopify admin, go to a customer order. Under "More actions", select "View order status page". Copy and paste the URL in Google Ads to check the URL.

4. You'll then need to confirm how you want to set up enhanced conversions. Select "Edit Code". Save.

5. The enhanced conversions code is not yet set up. You're about to do that. Once conversions come in, the tracking status of the conversion will say "Recording (processing enhanced conversions)":

Processing enhanced conversions

3. Configure the Conversion Code

The standard event code responsible for tracking that Google gives you will look something like:

<!-- Event snippet for Sales conversion page --> <script>   gtag('event', 'conversion', {     'send_to': 'AW-880346044/44BbCP7Vz3AQvIfkowM',     'value': ,     'currency': 'AUD',     'transaction_id': ''   }); </script>

Do not add this to your Shopify store. It's useless.

We're not just going to put sparkles and perfume on this bad boy. We're putting the standard tracking code under full anesthetic for a total body transformation. The good news is you don't need technical knowledge.

Here's the template code to copy:

<!-- START Google Ads enhanced conversions and conversions with cart data by DigitalDarts.com.au v1.7.1 --> {% assign UA-ID = "UA-PROPERTY_ID" -%}{%- comment -%}Google Analytics tracking ID.{%- endcomment -%} {%- assign AW-ID = "AW-GOOGLE_CONVERSION_ID" -%}{%- comment -%}Google Ads conversion ID.{%- endcomment -%} {%- assign product-id = "product-id_variant-id" -%}{%- comment -%}The format of the product IDs in the feed. 3 accepted values "sku" (SKU of the variant e.g. aga-012), "variant-id" (variant ID e.g. 21283160948841), or "product-id_variant-id" (product ID underscore then variant ID e.g. 28541777444969_21283160948841).{%- endcomment -%} {%- assign product-id-prefix = "shopify_US_" -%}{%- comment -%}Prefix to product-id. Leave blank if there's no prefix. This is likely needed if product-id_variant-id is selected so 28541777444969_21283160948841 becomes shopify_AU_28541777444969_21283160948841.{%- endcomment -%}  {%- comment -%}Below sets variables for Google conversions with cart data.{%- endcomment -%} {%- assign send_to = "AW-XXX/XXX" -%}{%- comment -%}The send_to variable from the Google conversion code.{%- endcomment -%} {%- assign aw_merchant_id = "YYY" -%}{%- comment -%}The Google Merchant Center ID{%- endcomment -%} {%- assign aw_feed_country = "AU" -%}{%- comment -%}The country associated with the feed. Use CLDR territory codes.{%- endcomment -%} {%- assign aw_feed_language = "EN" -%}{%- comment -%}The language associated with the feed. Use ISO 639-1 language codes{%- endcomment -%}  {%- comment -%}DO NOT EDIT AFTER HERE{%- endcomment -%} <!-- Global site tag (gtag.js) - Google Analytics --> <script async src="https://www.googletagmanager.com/gtag/js?id={{ UA-ID }}"></script> <script>   window.dataLayer = window.dataLayer || [];   function gtag(){dataLayer.push(arguments);}   gtag('js', new Date());   gtag('config', '{{ UA-ID }}');   gtag('config', '{{ AW-ID }}', { 'allow_enhanced_conversions': true }); </script>  {% if first_time_accessed %} <!-- START enhanced conversions --> <script> var enhanced_conversion_data = {   {% unless checkout.email == blank %}"email": "{{ checkout.email }}",{% endunless %}   {% unless billing_address.phone == blank %}"phone_number": "{{ billing_address.phone }}",{% endunless %}   {% unless billing_address.first_name == blank %}"first_name": "{{ billing_address.first_name }}",{% endunless %}   {% unless billing_address.last_name == blank %}"last_name": "{{ billing_address.last_name }}",{% endunless %}   "home_address": {     {% unless billing_address.street == blank %}"street": "{{ billing_address.street }}",{% endunless %}     {% unless billing_address.city == blank %}"city": "{{ billing_address.city }}",{% endunless %}     {% unless billing_address.province_code == blank %}"region": "{{ billing_address.province_code }}",{% endunless %}     {% unless billing_address.zip == blank %}"postal_code": "{{ billing_address.zip }}",{% endunless %}     {% unless billing_address.country_code == blank %}"country": "{{ billing_address.country_code }}"{% endunless %}   } }; </script> <!-- END enhanced conversions -->  <!-- START conversions with cart data --> <script type="text/javascript">   gtag('event', 'purchase', {     'send_to': '{{ send_to }}',     'transaction_id': '{{ order.order_number }}',     'value': Shopify.checkout.total_price_set.presentment_money.amount,     'currency': Shopify.checkout.total_price_set.presentment_money.currency_code,     'discount': discount(),     'aw_merchant_id': {{ aw_merchant_id }},     'aw_feed_country': '{{ aw_feed_country }}',     'aw_feed_language': '{{ aw_feed_language }}',     'items': items()   });   function discount(){     if (Shopify.checkout.discount == null) {       return 0;     } else {       return Shopify.checkout.discount.amount;     }   }   function items(){     var jsonarray = [];     for (var line_item_count = 0; line_item_count < Shopify.checkout.line_items.length; line_item_count++){       var jsonobj = {         id: {%- if product-id == "product-id_variant-id" -%}'{{ product-id-prefix }}' + Shopify.checkout.line_items[line_item_count].product_id + '_' + Shopify.checkout.line_items[line_item_count].variant_id{%- elsif product-id == 'variant-id' -%}Shopify.checkout.line_items[line_item_count].variant_id{%- elsif product-id == 'sku' -%}Shopify.checkout.line_items[line_item_count].sku{%- endif -%},         quantity: Shopify.checkout.line_items[line_item_count].quantity,         price: Shopify.checkout.line_items[line_item_count].line_price       };       jsonarray.push(jsonobj)     }     return jsonarray;   } </script> <!-- END conversions with cart data --> {% endif %} <!-- END Google Ads enhanced conversions and conversions with cart data by DigitalDarts.com.au v1.7.1 -->

You'll now edit the top part of the code:

  1. Replace UA-PROPERTY_ID with your Google Analytics tracking ID.
  2. Replace AW-GOOGLE_CONVERSION_ID with your Google Ads conversion ID.
  3. Set the ID variables based on your shopping feed:
    1. There's three accepted values of sku (SKU of the variant e.g. aga-012), variant-id (variant ID e.g. 21283160948841), or product-id_variant-id (product ID underscore then variant ID e.g. 28541777444969_21283160948841). To see what to select based on the ID format you're using in the feed, log into Merchant Center, click "Products" then "All products". View the column "Item ID". You may also find it helpful to log into the Shopify admin then cross-check a product's settings with Merchant Center. Bonus advanced tip: when editing product pages in the Shopify admin, the last number in the URL is the product ID. You can see if this value is used in the ID format of your feed.
    2. Replace shopify_US_ with the prefix for the ID format in your feed. Leave blank if there's no prefix. A prefix is only needed 99% of the time if you select product-id_variant-id. This is so 28541777444969_21283160948841 becomes shopify_AU_28541777444969_21283160948841 in order for the format to match the "Item ID" values you see in Merchant Center.
  4. Set your variables for Google conversions with cart data. AW-XXX/XXX is the send_to variable from the Google conversion code. This value is inside the "Event snippet" of the conversion.
  5. Replace YYY for the aw_merchant_id variable with your Google Merchant Center ID. You can get this number from the very top-right corner of your Merchant Center account. It is typically a seven to nine digit number.
  6. Replace AU with the country associated with the feed. Use CLDR territory codes.
  7. Replace EN with the language associated with the feed. Use ISO 639-1 language codes.
  8. Save the code in a notepad (.txt) file or some other document that will not modify characters. Do not use Microsoft Word as that alters characters. Alternatively, you can skip straight onto the next step without the preamble explanation about this code.

Here's a summary of what happens with this Google Ads conversion tracking code.

Firstly, it uses the currency and currency code from the user at checkout. The currency someone checks out with is called the "customer currency" or "presentment currency". Shopify makes this available through JavaScript at checkout. This saves us a load of pain in having to format the ever growing number of currencies accepted in Shopify.

Many currencies like the Euro use a comma for the decimal point. The Norwegian Krone has a comma for decimals then separates three digits with a full stop. Google requires the purchase value to be free of commas and to have the decimal point a full stop. Shopify handles this for all currencies with Shopify.checkout.total_price_set.presentment_money.amount so let's not recreate the wheel.

Google will accurately convert the currency to match the billing currency on your ad account. Google documentation says, "…if the Google Ads account driving a click that converts has a different billing currency, the conversion value will be converted to that account's currency using the average daily foreign exchange rate."

Secondly, the snippet uses the transaction_id parameter to prevent duplicate conversions when customers visit the thank you page a second time.

Thirdly, for whatever reason, implementing transaction_id does not always stop duplicate conversion data. The code we want to only run once is wrapped in the following liquid, which runs scripts only on their first time of the order status page: {% if first_time_accessed %}...{% endif %}

Fourthly, it uses cart data. The cart data feature adds a layer of information on top of each conversion. In Google Ads you get to see what items are purchased via ad clicks, which products convert better, what items are top sellers, and what profit was made. Thanks to cart data, you get to see what product was purchased even if it was different to the SKU clicked on in the shopping ad. I won't go more in-depth as to what it does for Google Ads management. I was the first to write about cart data early 2020 in a guest blog where you can read more about it.

4. Add the Google Ads Conversion Code to Shopify

1. Log into the admin section of your Shopify store. Go to "Settings" > "Checkout". Under the field "Additional scripts", paste your code.

2. Click "Save" in Shopify and you're done! You will now start receiving conversion cart data with enhanced conversions inside Google Ads.

3. We've never run into issues implementing the above code for our Google Ads Shopify clients. If you want to test what is output, you can view most of it from the source code. Edit the code by putting {% if first_time_accessed %} right before its closing {% endif %} tag then review the source code of a past order.

Not all values will be visible because the conversion tracking code contains the Shopify.checkout object. You need competency in Chrome Developer Tools to view what parameters are sent to the Google Ads script. You can also insert the following code before the last </script> tag then view the console in the browser's developer tools to see what the variables contain:

console.log({   'value': Shopify.checkout.total_price_set.presentment_money.amount,   'currency': Shopify.checkout.total_price_set.presentment_money.currency_code,   'discount': discount(),   'items': items() });

For other debugging, go to the conversions section in Google Ads, click on the conversion, then click on "Webpages" from the top to view what pages are triggering the conversion. There's also an enhanced conversions diagnostics report.

Alternative: Google Analytics Import

The primary method shared above will work with everyone. However, there is another way that requires Google Analytics. You may want to resort to this solution while you get the better method implemented.

1. Go through my Google Analytics setup for Shopify to get clean data in Analytics. Your goal is to have your source/medium report in Google Analytics with conversion data attributed to traffic sources like google / cpc :

2. Create a new conversion. Click "Import".

3. Select the type "Transaction" from the primary view you use in Google Analytics that has the most complete and accurate data.

4. Click "Import and Continue".

5. Once you've created the goal, click on it to edit it. The only value I suggest you change is the attribution model from "Last Click" to "Linear". Your settings will look like:

You are done importing transaction data from Google Analytics into Ads.

As a Shopify Marketing Expert and Google Partner, we've helped many Shopify stores grow with Google Ads. If you'd like us to take away the stress of doing paid advertising well, read about our Google Ads service for Shopify stores.

Joshua Ueberganghttps://www.digitaldarts.com.au/about

Joshua Uebergang is founder and Head of Strategy at Digital Darts. He helps Shopify stores get more of the right visitors and convert them into sales. At 6'9", yes, he plays basketball. Get extra tips and tricks from him to build your ecommerce store by entering your email above.

Related Posts

Get Your Free 7-Part Shopify Marketing Course:

Learn how to get more buyers to your store, little design tweaks that increase sales, and Shopify short-cuts that save you time managing your store. Join over 3,483 subscribers who have completed the course by entering your email:

We guarantee 100% privacy. Period.

Shopify Where to Add Google Conversion Tracking

Source: https://www.digitaldarts.com.au/google-ads-conversion-tracking-shopify

0 Response to "Shopify Where to Add Google Conversion Tracking"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel