Google Adwords Remarketing

How to add Google Dynamic Remarketing code in Magento

Magento is an open-source e-commerce platform written in PHP for e-commerce web sites, developed by Magento Inc. Magento provided very simple options for add any custom JavaScript and HTML code on the website through admin panel.

To add normal Adword Remarketing code follow this link instructions. But, if you are hoping to implement Google Adword Dynamic Remarketing  in magento , kindly go with below instructions.

However I have mention both option (i.e using magento connect admin panel as well as FTP access) to add dynamic remarketing code on the website.

Magento Ecommerce

If you already have Google Remarketing code then follow below steps, otherwise follow this link to get remarketing code from adwords Account.

Steps to add remarketing code on Magento

Using admin panel:

  1. Open this link in new window/tab or search GDRT in google search engine and open first result (i.e  https://www.magentocommerce.com link).
  2. Get/copy extension key.
  3. Login to magento admin
  4. In navigation bar go to System drop down will appear.
  5. Now in drop down click on Magento Connect.
  6. Install GDRT extension on Magento .
  7. Logout and login back to Magento admin.
  8. Now in drop down click on Configuration  inside System Menu.
  9. Go to GDRT setting (Left side option).
  10. Add  conversion id, conversion label(optional) and select product Id/sku as per merchent center details.
  11. Save.

Note:- Before adding any Extension on your website, please keep complete back up of your site. 

Dynamic remarketing code using FTP:

  • Login to FTP.
  • Open footer.phtml (file path: app->design->frontend-> base->default->template->page->html->footer.phtml).
  • Add the below code in Footer.phtml.
<?php $page_type = Mage::app()->getFrontController()->getRequest()->getControllerName();
if($page_type == 'index')
{
?>
    <script type="text/javascript">
     var google_tag_params = {
       ecomm_pagetype: 'home'
     };
  </script>
<?php } elseif($page_type == 'category') { ?>
  <script type="text/javascript">
     var google_tag_params = {
       ecomm_pagetype: 'category'
     };
  </script>
<?php 
} 
elseif($page_type == 'product') 
{ 
    $product_id = Mage::registry('current_product')->getId();
  $product_id = Mage::getModel('catalog/product')->load($product_id)->getSku();
  $product_price = Mage::registry('current_product')->getPrice();
?>
  <script type="text/javascript">
    var google_tag_params = {
      ecomm_pagetype: 'product',
      ecomm_prodid: '<?php echo $product_id; ?>',
      ecomm_totalvalue: <?php echo $product_price; ?>
    };
  </script>
<?php 
} 
elseif($page_type == 'cart') 
{ 
    $cart = Mage::getModel('checkout/session')->getQuote();
  foreach ($cart->getAllItems() as $item)
  {
    $product_id = $item->getProductId();
    $product_id = $item->getSku();
    $product_id_all = $product_id_all.',"'.$product_id.'"' ;
    $productPrice = $item->getProduct()->getPrice();
    $productPrice_all = $productPrice_all.','.$productPrice;
  }
   $product_id_all=substr($product_id_all, 1);
   $productPrice_all=substr($productPrice_all, 1);
?>
  <script type="text/javascript">
  var id=[<?php echo $product_id_all; ?>];
  var price=[<?php echo $productPrice_all; ?>];
  var google_tag_params = {
    ecomm_pagetype: 'cart',
    ecomm_prodid: id,
    ecomm_totalvalue: price
  };
  </script>
<?php 
} 
elseif($page_type == 'onepage') 
{ 
    $cart = Mage::getModel('checkout/session')->getQuote();
  foreach ($cart->getAllItems() as $item)
  {
    $product_id = $item->getProductId();
    $product_id = $item->getSku();
    $product_id_all = $product_id_all.',"'.$product_id.'"' ;
    $productPrice = $item->getProduct()->getPrice(); 
    $productPrice_all = $productPrice_all.','.$productPrice;
  }
  $product_id_all=substr($product_id_all, 1);
  $productPrice_all=substr($productPrice_all, 1);
?>
  <script type="text/javascript">
  var id=[<?php echo $product_id_all; ?>];
  var price=[<?php echo $productPrice_all; ?>];
  var google_tag_params = {
    ecomm_pagetype: 'purchase',
    ecomm_prodid: id,
    ecomm_totalvalue: price
  };
  </script>
<?php }else{ ?>
<script type="text/javascript">
  var google_tag_params = {
    ecomm_pagetype: 'other'
  };
  </script>
<?php } ?>

<script type="text/javascript">
/* <![CDATA[ */ 
var google_conversion_id = xxxxxxx; 
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/xxxxxx/?value=0&guid=ON&script=0"/>
</div>
</noscript>
  • Save Footer.pthml file and upload to server.
  • Login to magento
  • Go to System -> Cache Management.
  • Disable HTML Block.
  • Select all and  Refresh all cache.

Note :- Before editing any file on server, please keep back up of file. Base and Default directory can be change on then basis of package and template selection

Notes On Click

Share
Published by
Notes On Click

Recent Posts

Conversion and Remaketing code in BigCommerce

In this blog, you will see how to add Adwords Conversion Tracking and Remarkeing Code…

9 years ago

Ecommerce Tracking in OpenCart 2.3

Around 6 months back, I had published an article on “How to add GA e-commerce tracking…

9 years ago

Google Analytics Definition and Common Terms

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

9 years ago

What is Google Analytics and it’s Features?

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

9 years ago

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.…

9 years ago

Google Analytics and E-commerce Tracking in Miva Merchant

If you have gone through some of previous blog, you might have seen how to…

10 years ago