Categories: Google Adwords Remarketing

Dynamic Remarketing Code for Shopify

 This is my second blog on How to add Google Dynamic Remarketing Tag/Code in Shopify. In the previous blog I have mention that, how can you setup dynamic remarketing code in Shopify by add codes in individual pages.

But here I am providing you simple code snipet to setup dynamic remarketing tag on your website.

Instruction to setup dynamic remarketing:

1.) Login with Admin.

2.) Go to Online Store -> Themes.

3.) Add below code in main template file. before closing body tag (theme.liquid).

<!-- 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>

To add Google Dynamic remarketing code in checkout(confirmation page):

4.) Go to  Setting -> Checkout.

5.) Add the below code in Additional content and script  box inside Order processing, for order confirmation page.

<!-- Google dynamic remarketing tag for Order Confirmation page -->
<script type="text/javascript">
  {% if order.cancelled %}
    var google_tag_params = {
    ecomm_pagetype: 'other',
    ecomm_totalvalue: 0
    };
  {% else %}
    	var google_tag_params = {
           ecomm_prodid: [{% for line_item in order.line_items %} 'shopify_US_{{line_item.product.id}}_{{line_item.variant.id}}', {% endfor %}],
           ecomm_pagetype: 'purchase',
           ecomm_totalvalue: {{ subtotal_price | money_without_currency | remove: ","}}
        };
  {% endif %}
</script>
<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>

Note:- Replace XXXXXXXX with conversion id of remarketing code. above code is just for reference, so you can modify as per Shopify version and UI interface of your website. Feel free to get in touch.

Notes On Click

Share
Published by
Notes On Click
Tags: adword remarketingadwords dynamic remarketingShopify

Recent Posts

  • Adword Conversion Tracking
  • Google Adwords Remarketing

Conversion and Remaketing code in BigCommerce

In this blog, you will see how to add Adwords Conversion Tracking and Remarkeing Code in BigCommerce.BigCommerce is one of…

8 years ago
  • Google Analytics and Ecommerce Tracking

Ecommerce Tracking in OpenCart 2.3

Around 6 months back, I had published an article on “How to add GA e-commerce tracking in Opencart“. I am really thankful…

8 years ago
  • Google Analytics and Ecommerce Tracking

Google Analytics Definition and Common Terms

 If you have gone through our previous blog about Google Analytics, you might have sound understanding about Google Analytics and how it…

8 years ago
  • Google Analytics and Ecommerce Tracking

What is Google Analytics and it’s Features?

Do you want to know more about your visitors and how your content is performing?​ Whether you run a website…

8 years ago
  • Google Analytics and Ecommerce Tracking

How to Add Google Analytics in BigCommerce

In this blog, you will see how to add Google Analytics and E-commerce Tracking Code  in BigCommerce. BigCommerce is one of the…

8 years ago
  • Google Analytics and Ecommerce Tracking

Google Analytics and E-commerce Tracking in Miva Merchant

If you have gone through some of previous blog, you might have seen how to install google analytics, e-commerce tracking…

8 years ago