Last Updated: September 25, 2020
STEP 1
Activate Dynamic Remarketing in Google
- Go to Google Ads > Tools & Settings > Shared Library > Audience Manager > Audience Sources
- Click Set up tag in the “Google Ads tag” card
- Remarketing: Choose “Collect data on specific actions…“
- Business Type: Choose “Retail“
- Retail Parameters: Select All Parameters
- Click Save and continue.
- Click on Install Tag Yourself
- In the first code box, look for the number at the end of the first line of code and write it down or copy it. This is your Google Conversion Id — you will need it in the next step.
<!-- Global site tag (gtag.js) - Google Ads: 123456789 -->
- Click Continue and then Done
STEP 2
Install the Remarketing Code in Theme.liquid
In your store’s admin section go to:
- Online Store > Themes > Actions > Edit Code
- Expand the Snippets section and choose Add new snippet
- Call the snippet “adwords-remarketing“
- Paste the code below into the snippet
- Enter your google_conversion_id that you obtained in Step 1.8 above.
{% comment %}
Google Ads Dynamic Remarketing Script by Alex Czartoryski
https://business.czarto.com/2017/02/07/shopify-dynamic-remarketing-setup/
This version: Sept 30, 2020
The latest version of this script available here:
https://github.com/Czarto/ShopifyScripts/blob/master/snippets/adwords-remarketing.liquid
{% endcomment %}
{% comment %}Set to false if GTAG is already loaded on the page. Leave to true if unsure.{%endcomment%}
{% assign load_gtag = true %}
{% comment %} Enter your google conversion id below {% endcomment %}
{% assign google_conversion_id = 123456789 %}
{% assign shopify_store_country = 'US' %}
{% if shop.currency == 'CAD' %}
{% assign shopify_store_country = 'CA' %}
{% elsif shop.currency == 'AUD' %}
{% assign shopify_store_country = 'AU' %}
{% endif %}
{%if load_gtag %}
<!-- Global site tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-{{ google_conversion_id }}"></script>
{% endif %}
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-{{ google_conversion_id }}');
</script>
{% assign google_event = false %}
{% assign google_items = false %}
{% assign google_value = false %}
{% if template contains 'cart' %}
{% assign google_event = 'add_to_cart' %}
{% capture google_items %}{% for item in cart.items %}{'id':'shopify_{{ shopify_store_country }}_{{ item.product.id }}_{{ item.variant.id }}','google_business_vertical': 'retail'}{% unless forloop.last %}, {% endunless %}{% endfor %}{% endcapture %}
{% assign google_value = cart.total_price %}
{% elsif template contains 'collection' %}
{% assign google_event = 'view_item_list' %}
{% capture google_items %}{% for item in collection.products limit:5 %}{'id':'shopify_{{ shopify_store_country }}_{{ item.id }}_{{ item.variants.first.id }}','google_business_vertical': 'retail'}{% unless forloop.last %}, {% endunless %}{% endfor %}{% endcapture %}
{% elsif template contains 'product' %}
{% assign google_event = 'view_item' %}
{% capture google_items %}{'id':'shopify_{{ shopify_store_country }}_{{ product.id }}_{{ product.selected_or_first_available_variant.id }}','google_business_vertical': 'retail'}{% endcapture %}
{% assign google_value = product.selected_or_first_available_variant.price %}
{% elsif template contains 'search' %}
{% assign google_event = 'view_search_results' %}
{% capture google_items %}{% for item in search.results limit:5 %}{'id':'shopify_{{ shopify_store_country }}_{{ item.id }}_{{ item.variants.first.id }}','google_business_vertical': 'retail'}{% unless forloop.last %}, {% endunless %}{% endfor %}{% endcapture %}
{% endif %}
{% if google_event %}
<script>
gtag('event', '{{ google_event }}', {
'send_to': 'AW-{{ google_conversion_id }}',
{% if google_value %}'value': '{{ google_value | divided_by: 100.0 }}',{% endif %}
'items': [{{ google_items }}]
});
</script>
{% endif %}
The latest version of this code is available on Github
Add snippet to your Theme file
Open up Layout > theme.liquid and add the following line of code before the closing </head> tag:
{% include 'adwords-remarketing' %}
STEP 3
Install Remarketing in the Checkout Scripts
- In the very bottom left hand corner the Shopify Admin choose Settings and then Checkout
- Scroll down to the Additional Scripts section.
- Copy and paste the code below into the “Additional Scripts” field and update google_conversion_id with your value from step 1.8 as before.
{% comment %}
Google Ads Dynamic Remarkting Script by Alex Czartoryski https://business.czarto.com/
This version: Sep 30, 2020
The latest version of this script available here:
https://github.com/Czarto/ShopifyScripts/blob/master/settings/checkout/adwords-remarketing.liquid
{% endcomment %}
{% comment %}Set to false if GTAG is already loaded on the page. Leave to true if unsure.{%endcomment%}
{% assign load_gtag = true %}
{% if first_time_accessed %}
{% comment %} Enter your account specific values below {% endcomment %}
{% assign google_conversion_id = "123456789" %}
{% assign shopify_store_country = 'US' %}
{% if shop.currency == 'CAD' %}
{% assign shopify_store_country = 'CA' %}
{% elsif shop.currency == 'AUD' %}
{% assign shopify_store_country = 'AU' %}
{% endif %}
{%if load_gtag %}
<!-- Global site tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=AW-{{ google_conversion_id }}"></script>
{% endif %}
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'AW-{{ google_conversion_id }}');
</script>
<!-- Event snippet for Web Order conversion page -->
<script>
// Google Ads Remarketing
gtag('event', 'purchase', {
'send_to': 'AW-{{ google_conversion_id }}',
'value': '{{ total_price | divided_by: 100.0 }}',
'items': [{% for item in order.line_items %}{'id':'shopify_{{ shopify_store_country }}_{{ item.product.id }}_{{ item.variant.id }}','google_business_vertical': 'retail'}{% unless forloop.last %}, {% endunless %}{% endfor %}]
});
</script>
{% endif %}
Download the lastest version from Github
STEP 4
Verification
Once you’ve installed all your code, it’s time to run through your main pages (collection, product, cart, and purchase pages) with Google Tag Assistant installed to make sure there are no errors.
Next Steps
Configure your Remarketing Audiences
Now that your store is collecting dynamic remarketing data, the next step is to properly organize and segment your visitors into Purchasers, Cart Abandoners and Product Viewers. This is covered in the next post about Google Ads Remarketing Audiences.