Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ShopifyScripts/settings/checkout/adwords-remarketing.liquid
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
45 lines (37 sloc)
1.59 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% 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 %} |