AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Ads
1.9K members online now
1.9K members online now
Use Google Ads conversion tracking and reporting to measure your results. Have a question about Google Analytics? Post it here, on the Google Analytics Community!
Guide Me
star_border
Reply

Setting up dynamic remarketing code in Magento?

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hello,

 

does anyone know what code to add to magento for dynamic remarketing? The one from adwords doesn't work properly. 

 

<!-- Google Code per il tag di remarketing -->
<!--------------------------------------------------
I tag di remarketing possono non essere associati a informazioni di identificazione personale o inseriti in pagine relative a categorie sensibili. Ulteriori informazioni e istruzioni su come impostare il tag sono disponibili alla pagina: http://google.com/ads/remarketingsetup
--------------------------------------------------->
<script type="text/javascript">
var google_tag_params = {
ecomm_prodid: 'REPLACE_WITH_VALUE',
ecomm_pagetype: 'REPLACE_WITH_VALUE',
ecomm_totalvalue: 'REPLACE_WITH_VALUE',
};
</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&amp;guid=ON&amp;script=0"/>
</div>
</noscript>

 

What code should I put instead of REPLACE_WITH_VALUE?

 

Thank you

2 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Coltivazione I
September 2015

Re: Setting up dynamic remarketing code in Magento?

Google Employee
# 4
Google Employee

I don't have Magento so I haven't tried it especially with your version but you should try this (adapted from http://ecommppc.com/2014/09/05/setting-up-dynamic-remarketing-on-your-magento-webstore-using-google-...

 

on the product page (View.phtml):

<?php $_product = Mage::registry('current_product');?>
<?php if ($_product && $_product->getId()): ?>

<script type="text/javascript">
var google_tag_params = {
ecomm_prodid: '<?php echo $_product->getSku(); ?>',
ecomm_pagetype: 'product',
ecomm_totalvalue: '<?php echo $_product->getfinalprice(); ?>',
};
</script>
...

 

On the cart page (Cart.phtml):

<?php $items = Mage::getSingleton(‘checkout/session’)->getQuote()->getAllItems();?>

<script type="text/javascript">

var google_tag_params = {
'ecomm_prodid': [<?php foreach ($items as $item) {?>'<?php echo $item->getSku();?>',<?php } ?>],
'ecomm_pagetype': 'cart',
'ecomm_totalvalue': [<?php foreach ($items as $item) {?><?php echo $item->getPrice(); ?>,<?php } ?>]
}

</script>

...

 

On the purchase confirmation page (Success.phml):

<?php
$order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
$items = $order->getAllItems();
$total = $order->getGrandTotal();
?>

<script type="text/javascript">

var google_tag_params = {
'ecomm_prodid': [<?php foreach ($items as $item) {?>'<?php echo $item->getSku();?>’,<?php }?>],
'ecomm_pagetype': 'purchase',
'ecomm_totalvalue': '<?php echo $total; ?>'
}

</script>

...

View solution in original post

Re: Setting up dynamic remarketing code in Magento?

Participant ✭ ☆ ☆
# 2
Participant ✭ ☆ ☆
Hi,

There are existing addons for Magento which will enable dynamic remarketing. You should try them.

Siva.

Re: Setting up dynamic remarketing code in Magento?

Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭
Thanks, but all the addons I have found are for version 1.5 and up. My version is still 1.4.2.0.

Anyone knows how to do it?

Thank you
Marked as Best Answer.
Solution
Accepted by topic author Coltivazione I
September 2015

Re: Setting up dynamic remarketing code in Magento?

Google Employee
# 4
Google Employee

I don't have Magento so I haven't tried it especially with your version but you should try this (adapted from http://ecommppc.com/2014/09/05/setting-up-dynamic-remarketing-on-your-magento-webstore-using-google-...

 

on the product page (View.phtml):

<?php $_product = Mage::registry('current_product');?>
<?php if ($_product && $_product->getId()): ?>

<script type="text/javascript">
var google_tag_params = {
ecomm_prodid: '<?php echo $_product->getSku(); ?>',
ecomm_pagetype: 'product',
ecomm_totalvalue: '<?php echo $_product->getfinalprice(); ?>',
};
</script>
...

 

On the cart page (Cart.phtml):

<?php $items = Mage::getSingleton(‘checkout/session’)->getQuote()->getAllItems();?>

<script type="text/javascript">

var google_tag_params = {
'ecomm_prodid': [<?php foreach ($items as $item) {?>'<?php echo $item->getSku();?>',<?php } ?>],
'ecomm_pagetype': 'cart',
'ecomm_totalvalue': [<?php foreach ($items as $item) {?><?php echo $item->getPrice(); ?>,<?php } ?>]
}

</script>

...

 

On the purchase confirmation page (Success.phml):

<?php
$order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
$items = $order->getAllItems();
$total = $order->getGrandTotal();
?>

<script type="text/javascript">

var google_tag_params = {
'ecomm_prodid': [<?php foreach ($items as $item) {?>'<?php echo $item->getSku();?>’,<?php }?>],
'ecomm_pagetype': 'purchase',
'ecomm_totalvalue': '<?php echo $total; ?>'
}

</script>

...

Re: Setting up dynamic remarketing code in Magento?

Follower ✭ ✭ ✭
# 5
Follower ✭ ✭ ✭

Hi Maxime

 

I loaded the code you list above onto my view.phtml file. But the result is that those pages crash. I get a message that says:

"Parse error: syntax error unexpected $end in [pathfile] on line 190"

 

Line 190 only has the </script> tag in it

 

Can you advise on what might be wrong? I'm using magento 1.7.02

 

Cheers

 

Jorge

Re: Setting up dynamic remarketing code in Magento?

Google Employee
# 6
Google Employee
Hi Jorge,

Again I know almost nothing about Magento but the error you describe seems more like a syntax error in your code.
One way to debug that would be to add the code line by line starting with "<?php $_product = Mage::registry('current_product');?>" to see if there's any particular line that triggers the error.
You can also share your code here.

Otherwise, a simpler option might be to install one of the Magento add-ons for Dynamic Remarketing:
http://www.magentocommerce.com/magento-connect/anaraky-gdrt-google-dynamic-remarketing-tag-for-magen...
I have not tested it myself but the reviews look pretty good.

- Maxime

Re: Setting up dynamic remarketing code in Magento?

[ Edited ]
Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭

HI.. Thank you Maxime, for the post. In a way I can include these blocks in my pages. But I wonder what will be the value of parameters (ecomm_prodid,ecomm_pagetype,ecomm_totalvalue) in the category pages, cms pages and home page.

Thanks.

Kishore

Re: Setting up dynamic remarketing code in Magento?

Google Employee
# 8
Google Employee
I wouldn't worry too much about category pages, cms pages and the home page, they are not the most interesting to track. Purchase intent is much stronger on product pages and shopping cart page.

Re: Setting up dynamic remarketing code in Magento?

Visitor ✭ ✭ ✭
# 9
Visitor ✭ ✭ ✭

Hello Maxime,
I am getting what you are trying to say. But if at all I want to include the script for those pages for some reason like, I want to track on which category page people spend more time , then what should be the values. Because in that page I can't find a particular value for ecomm_prodid and ecomm_totalvalue. The only value I get is "category" which is for ecomm_pagetype. So how can I find the other values ?

 

Thanks.
Kishore

Re: Setting up dynamic remarketing code in Magento?

Google Employee
# 10
Google Employee
If you really want to pass ecomm_prodid on category pages, the best practice is to pass a maximum of 3 values as a JavaScript array (e.g. ecomm_prodid = ['1234','5678','90'])

I don't know much about magento so I can't tell you what the server-side code is to generate that JS array on category pages.

Very few clients actually pass product ids on category pages (and none on cms of home pages)