Untitled

 avatar
unknown
plain_text
4 years ago
2.6 kB
23
Indexable
!! replace all instances of CONVERSION_ID with the google ads id


// 1. Modify the site's google ads Gtag to this:

  <!-- Global site tag (gtag.js) - Google AdWords: 362119061 -->
  <script async src="https://www.googletagmanager.com/gtag/js?id=AW-362119061"></script>
  <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());
    gtag('config', 'AW-362119061', {
      'send_page_view': false
    });
  </script>


// 2. Include the following in the bottom of the theme.liquid file before the closing body tag:

{% include 'lp-dynamic-remarketing' %}


// 3. Add a new Snippet file in the theme editor named "lp-dynamic-remarketing"

// 4. Add the code below to the new snippet and save


<!-- Google Dynamic Remarketing for Shopify theme.liquid -->
{% if template contains 'index' %}
    <script type="text/javascript">
	var google_tag_params = {
		ecomm_prodid: '',
		ecomm_pagetype: 'home',
		ecomm_totalvalue: 0,
	};
	</script>
{% elsif template contains 'collection' %}
	<script type="text/javascript">
	var google_tag_params = {
		ecomm_prodid: '',
		ecomm_pagetype: 'category',
		ecomm_totalvalue: 0,
	};
	</script>
{% elsif template contains 'product' %}
	<script type="text/javascript">
	var google_tag_params = {
		ecomm_prodid: '{{product.id}}',
		ecomm_pagetype: 'product',
		ecomm_totalvalue: {{ product.selected_or_first_available_variant.price | money_without_currency | remove: "," }}
	};
	</script>
{% elsif template contains 'cart' %}
<script type="text/javascript">
var google_tag_params = {
    ecomm_prodid: [{% for item in cart.items %}'{{item.product.id}}'{% unless forloop.last %},{% endunless %}{% 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_prodid: '',
		ecomm_pagetype: 'searchresults',
		ecomm_totalvalue: 0,
	}
	</script>
{% else %}
	<script type="text/javascript">
	var google_tag_params = {
		ecomm_prodid: '',
		ecomm_pagetype: 'other',
		ecomm_totalvalue: 0,
	};
	</script>
{% endif %}

<script>
gtag('event', 'page_view', {
    'send_to': 'AW-362119061',
    'ecomm_pagetype': google_tag_params.ecomm_pagetype,
    'ecomm_prodid': google_tag_params.ecomm_prodid,
    'ecomm_totalvalue': google_tag_params.ecomm_totalvalue,
});
</script>
<!-- End LP Google Dynamic Remarketing for Shopify theme.liquid -->
Editor is loading...