0

My magento site has an extension which is used for google analytics and remarketing. I don't know how this thing work in magento as I am new to magento. I googled about this and got to know that a script is written in the head part( as required), which take some parameter for managing these things. Now I have to add google dynamic remarketing tags throughout the site. I read the article. but I can't get any clear picture about what should I do ? In which page should I write the script ?

Please help.Thanks.

2
  • do you know which module you are using for google analytics and remarketing?
    – rob3000
    Oct 2, 2015 at 1:46
  • Yes. The extension is called "Aromicon (Gua)", by which it adds some script related to google analytics and remarketing in every page. But I want to know , Whether would I modify that extension or add some other scripts in specific pages for enabling google dynamic remarketing . Oct 2, 2015 at 7:04

3 Answers 3

1

OK i don't think the "Aromicon (Gua)" will be able to help you achieve this but you can do this yourself by adding a template and some JavaScript to your page.

First lets create a template to hold the initilization of the script and out custom variables. In your local.xml inside your theme app/design/frontend/THEME/PACKAGE/layout/local.xml look at adding the following inside the <default> layout handle:

<default>
    <reference name="before_body_ends">
         <block type="core/template" name="custom.google.remarketing" template="page/remarketing.phtml" />
    </reference>
</default>

Now in your template that you just added app/design/frontend/THEME/PACKAGE/page/remarketing.phtml you can look at adding the following:

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

source: https://support.google.com/adwords/answer/3103357?hl=en-AU

Now that you have the script on the page you can add your custom params as you see fit to different pages such as:

<cms_index_index>
        <reference name="before_body_ends">
             <block type="core/template" name="custom.google.remarketing.params" template="page/remarketing/params.phtml"  after="custom.google.remarketing"/>
        </reference>
    </cms_index_index>

Then in your page/remarketing/params.phtml template:

<script type="text/javascript">
var google_tag_params = {
flight_destid: "REPLACE_WITH_STRING_VALUE", 
flight_pagetype: "REPLACE_WITH_STRING_VALUE",
flight_totalvalue: REPLACE_WITH_NUMBER_VALUE
};
</script>

You may want to change the block type to your own block so that you can add the params you need but this should hopefully point you into the right direction.

Another option if you just needed to add just the remarketing code without any dynamic variables you could look at installing the Google Tag Manager and manage all your scripts from there.

4
  • Hello @rob3000.. I am able to create a block and include script with dynamic parameters in the respective pages. But first I have disabled the extension and include my code. So now only some specific pages like home, cms, product page have the code. All other pages don't have any which was previously included by the extension. Now I wonder how come the functionality of the extension be fulfilled ? Oct 12, 2015 at 7:46
  • @KishorePatra What handle did you add the block under? is should go under <default>
    – rob3000
    Oct 12, 2015 at 8:23
  • I have made different html file for different pages like for product page, prodcode.phtml. For cms page, cmscode.phtml.. Then I just update them in the local. xml like in <category_product_view> for product page..etc.. Oct 12, 2015 at 9:06
  • @KishorePatra just updated my answer to have different params per page.
    – rob3000
    Oct 13, 2015 at 0:23
1

Following are the several page types for dynamic remarketing -:

  • home
  • searchresults
  • category
  • product
  • cart
  • purchase
  • other

For each page type you need the following different values -:

'ecomm_pagetype' => '',

'ecomm_prodid' => '',

'ecomm_category' => '', //optional

'ecomm_pvalue' => 0, //optional

'ecomm_totalvalue' => 0

for example for product page you can set the above values using the following snippet

protected function getJsConfigParams(){
    $_product = Mage::registry('current_product');
    if($_product && $_product instanceof Mage_Catalog_Model_Product){
      $_params = array();
      $_params['ecomm_prodid'] = $_product->getEntityId;
      $_params['ecomm_totalvalue'] =  (float)$_product->getFinalPrice();
      $_params['ecomm_pvalue'] = (float)$_product->getFinalPrice();     
      if(Mage::registry('current_category')){
        $_params['ecomm_category'] = Mage::registry('current_category')->getName();
      }

      return $_params;
    }
}

Here you can use this on frontend design template -:

<script type="text/javascript">
    var google_tag_params = <?php echo $this->getJsConfigParams(); ?>;
</script>
<?php endif;?>
<script type="text/javascript">
/* <![CDATA[ */
    var google_conversion_id = 'XXXXXXXXXXXX'
    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/XXXXXXXXXXXX/?value=0&amp;guid=ON&amp;script=0"/>
</div>
</noscript>

Hope this gives you an idea to achieve this in Magento if you are a developer but if not then you can the following extension which has everything you need to implement dynamic remarketing on your website.

https://www.scommerce-mage.com/magento-google-dynamic-remarketing-tag.html

0

I followed @rob3000's answer above and it was mostly what I wanted. Changes I made were that I created a params file for each pagetype as they are handled slightly differently. So we ended up with params-home.phtml, params-cart.phtml, etc.

Then included them in the proper locations with the layout file. We also wanted the actual tag to show up after the params code, so we did this inside each of the params files:

echo $this->getLayout()->createBlock('core/template')->setTemplate('page/remarketing/tag.phtml')->toHtml();

That might not be best practice, however it made sense for our application.

We also added output="toHtml" on the layout file to simple output the params+tag code and not have to modify the existing templates.

In addition we grouped all files in a remarketing directory inside of the page one, so our hierarchy looked like this:

app/design/frontend/THEME/PACKAGE/page/remarketing/...
    params-xxx.phtml
    params-yyy.phtml
    tag.phtml

Hope this helps someone down the line.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.