Last active
July 5, 2018 23:11
-
-
Save rickydazla/5f04f84505fd54645c9e0d2a4474d4d4 to your computer and use it in GitHub Desktop.
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 %} | |
See here for getting Conversion ID and Label | |
https://www.en.advertisercommunity.com/t5/AdWords-Tracking-and-Reporting/Finding-you-Google-Adwords-Conversion-ID/td-p/1119060# | |
{% endcomment %} | |
{% if first_time_accessed %} | |
{% assign google_conversion_id = 123456 %} | |
{% assign google_conversion_label = 'xyz789' %} | |
{% assign shopify_store_country = 'US' %} | |
<script type="text/javascript"> | |
var google_tag_params = { | |
ecomm_prodid: [{% for item in order.line_items %}'shopify_{{ shopify_store_country }}_{{ item.product.id }}_{{ item.variant.id }}'{% unless forloop.last %}, {% endunless %}{% endfor %}], | |
ecomm_pagetype: 'purchase', | |
ecomm_totalvalue: {{ total_price | money_without_currency | remove: ',' }} | |
}; | |
</script> | |
<script type="text/javascript"> | |
/* <![CDATA[ */ | |
var google_conversion_id = {{ google_conversion_id }}; | |
var google_conversion_label = {{ google_conversion_label }}; | |
var google_custom_params = window.google_tag_params; | |
var google_remarketing_only = true; | |
/* ]]> */ | |
</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="//googleads.g.doubleclick.net/pagead/viewthroughconversion/{{ google_conversion_id }}/?guid=ON&script=0"/> | |
</div> | |
</noscript> | |
{% endif %} |
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 -%} | |
Remarketing | |
{%- endcomment -%} | |
{% assign google_conversion_id = 123456 %} | |
{% assign google_conversion_label = 'xyz789' %} | |
{% assign shopify_store_country = 'US' %} | |
{%- assign primaryTemplate = template | split: '.' | first -%} | |
{%- case primaryTemplate -%} | |
{%- when 'product' -%} | |
<script type="text/javascript"> | |
var json_product = {{ product | json }}; | |
var ecomm_prodid=[]; | |
for(var i=0;i<json_product.variants.length;i++) | |
ecomm_prodid.push(json_product.variants[i].id); | |
var google_tag_params = { | |
ecomm_prodid: ecomm_prodid, | |
ecomm_pagetype: 'product', | |
ecomm_totalvalue: parseFloat('{{ product.price | money_without_currency | remove: "," }}') | |
}; | |
</script> | |
{%- when 'collection' -%} | |
<script type="text/javascript"> | |
var google_tag_params = { | |
ecomm_prodid: '', | |
ecomm_pagetype: 'category', | |
ecomm_totalvalue: 0 | |
}; | |
</script> | |
{%- when 'cart' -%} | |
<script type="text/javascript"> | |
var id = new Array(); | |
{% for item in cart.items %} | |
id.push('{{ item.variant.id }}'); | |
{% endfor %} | |
var google_tag_params = { | |
ecomm_prodid: id, | |
ecomm_pagetype: 'cart', | |
ecomm_totalvalue: parseFloat('{{ cart.total_price | money_without_currency | remove: "," }}') | |
}; | |
</script> | |
{%- when 'search' -%} | |
<script type="text/javascript"> | |
var google_tag_params = { | |
ecomm_prodid: '', | |
ecomm_pagetype: 'searchresults', | |
ecomm_totalvalue: 0 | |
}; | |
</script> | |
{%- when 'index' -%} | |
<script type="text/javascript"> | |
var google_tag_params = { | |
ecomm_prodid: '', | |
ecomm_pagetype: 'home', | |
ecomm_totalvalue: 0 | |
}; | |
</script> | |
{%- else -%} | |
<script type="text/javascript"> | |
var google_tag_params = { | |
ecomm_prodid: '', | |
ecomm_pagetype: 'other', | |
ecomm_totalvalue: 0 | |
}; | |
</script> | |
{%- endcase -%} | |
<script type="text/javascript"> | |
/* <![CDATA[ */ | |
var google_conversion_id = {{ google_conversion_id }}; | |
var google_conversion_label = {{ google_conversion_label }}; | |
var google_custom_params = window.google_tag_params; | |
var google_remarketing_only = true; | |
/* ]]> */ | |
</script> | |
<script type="text/javascript" src="https://www.googleadservices.com/pagead/conversion.js"></script> | |
<noscript> | |
<div style="display:inline;"> | |
<img height="1" width="1" style="border-style:none;" alt="" src="https://googleads.g.doubleclick.net/pagead/viewthroughconversion/{{ google_conversion_id }}/?value=0&guid=ON&script=0"/> | |
</div> | |
</noscript> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment