<!-- Google dynamic remarketing tag for home,product, category,cart and searchresult page ( theme.liquid )-->
{% if template contains 'product' %}
<script type="text/javascript">
var json_product = {{ product | json }};
</script>
<script>
var ecomm_prodid=[];
for(var i=0;i<json_product.variants.length;i++)
ecomm_prodid.push('shopify_US_{{product.id}}_'+json_product.variants[i].id);
</script>
<script type="text/javascript">
var google_tag_params = {
ecomm_prodid: ecomm_prodid,
ecomm_pagetype: 'product',
ecomm_totalvalue: {{ product.price | money_without_currency | remove: ","}}
};
</script>
{% elsif template contains 'collection' %}
<script type="text/javascript">
var google_tag_params = {
ecomm_pagetype: 'category',
ecomm_totalvalue: 0
};
</script>
{% elsif template contains 'cart' %}
<script type="text/javascript">
var google_tag_params = {
ecomm_prodid: [{% for item in cart.items %}'shopify_US_{{item.product.id}}_{{item.variant.id}}',{% endfor %}],
ecomm_pagetype: 'cart',
ecomm_totalvalue: {{ cart.total_price | money_without_currency | remove: ","}}
};
</script>
{% elsif template contains 'search' %}
<script type="text/javascript">
var google_tag_params = {
ecomm_pagetype: 'searchresults',
ecomm_totalvalue: 0
};
</script>
{% elsif template contains 'index' %}
<script type="text/javascript">
var google_tag_params = {
ecomm_pagetype: 'home',
ecomm_totalvalue: 0
};
</script>
{% else %}
<script type="text/javascript">
var google_tag_params = {
ecomm_pagetype: 'other',
ecomm_totalvalue: 0
};
</script>
{% endif %}
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = XXXXXXXX;
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/XXXXXXXX/?value=0&guid=ON&script=0"/>
</div>
</noscript>