3

How I can put the Google AdWords Remarketing in my code? Is there an extension for magento ?

2

3 Answers 3

3

I start at the beginning to make it all clear.

1. Create a New Macro in GTM

Head over to GTM and create a new data layer variable macro. Name it as google tag params and variable name as google_tag_params and save it.

2. Create a Firing Rule

Create a new firing rule with condition [event equals fireRemarketingTag] and save it.

3. Create a Remarketing Tag

Create a new remarketing tag and fill up your conversion id. Choose firing rule and the datalayer we created in above process and save it.

We are done with GTM. Now we should head over to Magento. Just paste the below codes on the appropriate templates.

4. template/catalog/product/View.phtml

Paste the below code on your product view template. You can find the file inside the catalog folder.

<?php $_product = Mage::registry("current_product");?>
<?php if ($_product && $_product->getId()): ?>
<script>
dataLayer.push({
"event": "fireRemarketingTag",
"google_tag_params": {
"ecomm_prodid": "<?php echo $_product->getSku(); ?>",
"ecomm_pagetype": "product",
"ecomm_totalvalue": "<?php echo $_product->getfinalprice(); ?>"
}
});
</script>

5. template/checkout/Cart.phtml

Paste the below code on your cart template. You can find the file inside the checkout folder.

<?php $items = Mage::getSingleton("checkout/session")->getQuote()->getAllItems();?>
<script>
dataLayer.push({
"event": "fireRemarketingTag",
"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>

6. template/checkout/Success.phtml

Paste the below code on your success template. You can find the file inside checkout folder.

<?php
$order = Mage::getModel("sales/order")->loadByIncrementId($this->getOrderId());
$items = $order->getAllItems();
$total = $order->getGrandTotal();
?>
<script>
dataLayer.push({
"event": "fireRemarketingTag",
"google_tag_params": {
"ecomm_prodid": [<?php foreach ($items as $item) {?>'<?php echo $item->getSku();?>",<?php }?>],
"ecomm_pagetype": "purchase",
"ecomm_totalvalue": "<?php echo $total; ?>"
}
});
</script>

Publish your GTM and We are done! Now your dynamic remarketing should be working!

I did it the same way in my Magento installation and it works fine

0

Depending on what kind of google tracking you are using you have a few different way to use:

1) If only add a custom code and should be in all the Magento page, use the "Miscellaneous Scripts" value going to admin section, System > Configuration > Design > HTML Head - Miscellaneous Scripts. (This will be included before head closing tag in page HTML.)

2) By native Magento already have Google Analytics tracking code and you can find this configuration going to admin section System > Configuration > Google API - Google Analytics.

3) If you are looking something more complex and use the Google adWords I used the extension magento connect link: https://www.magentocommerce.com/magento-connect/luka-google-adwords-conversion-tracking.html.

I hope this will help you.

-2

You don't really need an extensions just to add the codes into every page.

You can just add the codes in your Magento Admin under System --> Configuration --> Design --> Footer --> Miscellaneous HTML.

3
  • Thank you very much. to track conversions from its site I have to put the code or? Sep 14, 2015 at 5:43
  • I believe the code for remarketing and conversions are different but they can be added at the same place listed above. Sep 27, 2015 at 10:32
  • That's path to put one code in all pages. Jun 8, 2016 at 22:32

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