remarketing Google prestashop 1.5 - Ecommerce x PrestaShop [ARCHIVE BOARD] - PrestaShop

Jump to content

Photo

remarketing Google prestashop 1.5

remarketing Google prestashop

#1

Posted 11 March 2014 - 05:43 PM

RomuGb

    PrestaShop Apprentice

  • Members
  • PipPip
  • 45 Active Posts

Hi everyone !

 

i have been searching hard to add the remarketing google script in prestashop 1.5.3 :

Here is my solution, hope this will help many !!!

 

In /httpdocs/themes/yourtheme/footer.tpl

 

At the end of the code, just before </body> :


<!-- google remarketing script -->
	
	<script type='text/javascript'>
	var google_tag_params = {
	{if $page_name == 'index'}
		ecomm_pagetype: 'home'
	{elseif $page_name == 'order'}
		ecomm_prodid: [{foreach from=$products item=product name=prodid}'{$product.id_product}'{if $smarty.foreach.prodid.last}{else},{/if}{/foreach}],
		ecomm_pagetype: 'cart',
		ecomm_totalvalue: '{convertPrice price=$cart->getOrderTotal(true)}'
	{elseif $page_name == 'product'}
		ecomm_prodid: '{$product->id}',
		ecomm_pagetype: 'product',
		ecomm_totalvalue: '{$product->getPrice(false, $smarty.const.NULL, $priceDisplayPrecision)}'
	{elseif $page_name == 'order-confirmation'}
		ecomm_pagetype: 'purchase',
		ecomm_totalvalue: '{$total_to_pay}'
	{elseif $page_name == 'category'}
		ecomm_pagetype: 'category'
	{else}
	
	{/if}
	};
	</script>
	{literal}
	<script type="text/javascript">
	/* <![CDATA[ */
	var google_conversion_id = xxxx mettre ici votre code xxxxxx;
	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/xxxxmettre_ici_votre code_xxxxxx/?value=0&amp;guid=ON&amp;script=0"/>
	</div>
	</noscript>
	{/literal}

</body>
</html>

In  /httpdocs/controllers/front/OrderConfirmationController.php

 

(Its better to add this in the override OrderConfirmationController.php but i dont know how to do it, if i could have some help on this ?)

	public function initContent()
	{
		parent::initContent();

		$this->context->smarty->assign(array(
			'is_guest' => $this->context->customer->is_guest,
			'HOOK_ORDER_CONFIRMATION' => $this->displayOrderConfirmation(),
			'HOOK_PAYMENT_RETURN' => $this->displayPaymentReturn()
		));

		if ($this->context->customer->is_guest)
		{
			$this->context->smarty->assign(array(
				'id_order' => $this->id_order,
				'reference_order' => $this->reference,
				'id_order_formatted' => sprintf('#%06d', $this->id_order),
				'email' => $this->context->customer->email
			));
			/* If guest we clear the cookie for security reason */
			$this->context->customer->mylogout();
		}

		/* google remarketing */
		
		$order = new Order($this->id_order);
	    $cart = new Cart($order->id_cart);
	    $this->context->smarty->assign(array(
	    'total_to_pay'=>$order->getOrdersTotalPaid()
	    ));
		/* google remarketing */
		
		$this->setTemplate(_PS_THEME_DIR_.'order-confirmation.tpl');
	}

Enjoy !!!



#2

Posted 22 April 2014 - 04:36 PM

ajnglagla

    PrestaShop Apprentice

  • Members
  • PipPip
  • 68 Active Posts

if you want to see the prices right, this code

{$product->getPrice(false, $smarty.const.NULL, $priceDisplayPrecision)} 

must be chaged to

{$product->getPrice(true, $smarty.const.NULL, $priceDisplayPrecision)}


#3

Posted 22 April 2014 - 04:40 PM

ajnglagla

    PrestaShop Apprentice

  • Members
  • PipPip
  • 68 Active Posts

and also you may need to LANG ISO CODE after your product id.

(ex: "473-tr")



#4

Posted 22 April 2014 - 05:09 PM

Dh42

    PrestaShop Native Modules Developer

  • Global Moderators
  • 5469 Active Posts

There is a module by business tech that does the remarketing code automatically. 



#5

Posted 08 May 2014 - 01:10 PM

Alexgaw

    PrestaShop Enthusiast

  • Members
  • PipPip
  • 134 Active Posts

Hi,

 

I cannot get re marketing to work on PS1.606. Google chrome tag assistant give this error.

 

Error: No HTTP response detected

 

Have any of you got hit thing working on 1.606?

 

Cheers,

/Alex



#6

Posted 20 May 2014 - 01:52 PM

criacaosites

    PrestaShop Apprentice

  • Members
  • PipPip
  • 97 Active Posts

I have same error no http, try compress js. In my case don't work because my theme lost configuration of layout.


Fazemos o melhor pelo seu Prestashop!


#7

Posted 07 July 2014 - 03:55 PM

franzneves

    PrestaShop Enthusiast

  • Members
  • PipPip
  • 102 Active Posts

I have same error no http



#8

Posted 10 July 2014 - 05:01 PM

ajensen27

    PrestaShop Enthusiast

  • Members
  • PipPip
  • 472 Active Posts

Code worked perfectly RomuGb.... Thanks!!



#9

Posted 11 July 2014 - 08:47 AM

RomuGb

    PrestaShop Apprentice

  • Members
  • PipPip
  • 45 Active Posts

Code worked perfectly RomuGb.... Thanks!!

 

Thanks Ajensen27 !



#10

Posted 11 July 2014 - 08:49 AM

RomuGb

    PrestaShop Apprentice

  • Members
  • PipPip
  • 45 Active Posts

I have same error no http

 

 

I have same error no http, try compress js. In my case don't work because my theme lost configuration of layout.

 

 

Hi,

 

I cannot get re marketing to work on PS1.606. Google chrome tag assistant give this error.

 

Error: No HTTP response detected

 

Have any of you got hit thing working on 1.606?

 

Cheers,

/Alex

 

Ok if you find a solution for 1.6 version please post it here. It will help others.

Thanks.

 

Romu



#11

Posted 12 July 2014 - 02:23 AM

franzneves

    PrestaShop Enthusiast

  • Members
  • PipPip
  • 102 Active Posts

I need solution too - 1.6.0.6



#12

Posted 14 July 2014 - 06:05 PM

ajensen27

    PrestaShop Enthusiast

  • Members
  • PipPip
  • 472 Active Posts

Thanks Ajensen27 !

 

I spoke to soon  :)

 

I'm getting the following error in my Google Adwords account under the remarketing tool. Any ideas?

 

Your Google Analytics tag is active
We haven't detected custom parameters for Retail
The tag is active but we couldn't find any custom parameters.
Check that the remarketing tag is implemented correctly. Custom parameters are necessary to enable dynamic remarketing.
We didn't find the custom parameter "ecomm_prodid"
 

 


Edited by ajensen27, 14 July 2014 - 06:07 PM.


#13

Posted 15 September 2014 - 04:44 PM

Tia©

    PrestaShop Apprentice

  • Members
  • PipPip
  • 47 Active Posts

RomuGb thank you very much!! Very useful solution, thank's again!

 

For override i think you can copy the OrderConfirmationController.php modified file in youshopdirectory/override/classes/

Remember to clean the cache dir /yourshopdir/classes/cache/


Prestashop 1.5.6.1

 

<?xml version="1.0" encoding="UTF-8" ?><module><name>Tia</name></module>


#14

Posted 29 March 2015 - 10:10 AM

mnmak

    PrestaShop Apprentice

  • Members
  • PipPip
  • 86 Active Posts

Enjoy !!!

Hello RomuGb, thank you for the great code. It works perfectly, unfortunately it doesnt pass some of the parameters corectly, namely: The tag is not passing all required values for "ecomm_pagetype". I think the problem is for "cart" and "order". Any advice?
This is the code:
 
<script type='text/javascript'>
var google_tag_params = {
{if $page_name == 'index'}
ecomm_pagetype: 'home'
{elseif $page_name == 'order'}
ecomm_prodid: [{foreach from=$products item=product name=prodid}'{$product.id_product}'{if $smarty.foreach.prodid.last}{else},{/if}{/foreach}],
ecomm_pagetype: 'cart',
ecomm_totalvalue: '{convertPrice price=$cart->getOrderTotal(true)}'
{elseif $page_name == 'product'}
ecomm_prodid: '{$product->id}',
ecomm_pagetype: 'product',
ecomm_totalvalue: '{$product->getPrice(true, $smarty.const.NULL, $priceDisplayPrecision)}'
{elseif $page_name == 'order-confirmation'}
ecomm_pagetype: 'purchase',
ecomm_totalvalue: '{$total_to_pay}'
{elseif $page_name == 'category'}
ecomm_pagetype: 'category'
{else}
{/if}
};
</script>
 
PS 1.6.0.11

Edited by mnmak, 29 March 2015 - 10:29 AM.


#15

Posted 10 May 2015 - 10:47 AM

mir-aus

    PrestaShop Enthusiast

  • Members
  • PipPip
  • 225 Active Posts

There is a module by business tech that does the remarketing code automatically. 

Hi,

I used your module! it doesn't works and also I tray use what exactly "mnmak said, bust still same error in google:

We haven't detected the Google Analytics remarketing functionality on your website

 

any suggestion?

I have PS. 1.6.0.6



#16

Posted 26 August 2015 - 03:48 PM

David Niry

    PrestaShop Enthusiast

  • Members
  • PipPip
  • 172 Active Posts

Guys, whether you are using our module (http://addons.presta...ng-dynamic.html), or doing this manually, initially, there will be a wait time during which Adwords will tell you "We haven't detected the Google Analytics remarketing functionality on your website".

 

This is simply because Google needs to crawl all your site and index it again before the tags are detected. Just be patient and it will eventually be fine (it can take from a couple days up to a week or so, depending on the frequency at which Google visits your website).

 

I hope this clears up any confusion. We have used our module for our own remarketing campaigns in the past and went through the exact same thing. After a few days, it worked !



#17

Posted 29 October 2015 - 12:05 AM

lysybogu

    PrestaShop Newbie

  • Members
  • Pip
  • 11 Active Posts

Ok if you find a solution for 1.6 version please post it here. It will help others.

Thanks.

 

Romu

 

In presta 1.6 You must disable "Move the javascript to the end" option at the BO -> Advanced setting -> Preferences

And then retargeting tags works great!


Podarunkowo.pl - Prezenty, upominki

#18

Posted 23 November 2015 - 07:42 PM

Stahoo

    PrestaShop Apprentice

  • Members
  • PipPip
  • 33 Active Posts

Hello,

thanks for great post, finally some complete tutorail that works. Tested with Prestashop 1.6.1 and it works!

Regards



#19

Posted 14 January 2016 - 08:30 PM

Mizi91

    PrestaShop Newbie

  • Members
  • Pip
  • 8 Active Posts

PS 1.6.0.11:

 

I use this version of script:

	<script type='text/javascript'>
	var google_tag_params = {
	{if $page_name == 'index'}
		ecomm_pagetype: 'home'
	{elseif $page_name == 'order-opc'}
		ecomm_prodid: [{foreach from=$products item=product name=prodid}'{$product.id_product}'{if $smarty.foreach.prodid.last}{else},{/if}{/foreach}],
		ecomm_pagetype: 'cart',
		ecomm_totalvalue: '{convertPrice price=$cart->getOrderTotal(true)}'
	{elseif $page_name == 'product'}
		ecomm_prodid: '{$product->id}',
		ecomm_pagetype: 'product',
		ecomm_totalvalue: '{$product->getPrice(true, $smarty.const.NULL, $priceDisplayPrecision)}'
	{elseif $page_name == 'order-confirmation'}
		ecomm_pagetype: 'purchase',
		ecomm_totalvalue: '{$total_to_pay}'
	{elseif $page_name == 'category'}
		ecomm_pagetype: 'category'
	{else}
	
	{/if}
	};
	</script>

But i get error: 

 

 
Number field should not be quoted: 'ecomm_totalvalue'

 

Does anyone know where is the mistake?



#20

Posted 14 January 2016 - 09:22 PM

lysybogu

    PrestaShop Newbie

  • Members
  • Pip
  • 11 Active Posts
Mizi91 find every line that cointains
ecomm_totalvalue:

and delete quotes from there, so e.g. line:
ecomm_totalvalue: '{$total_to_pay}'

must look like this:
ecomm_totalvalue: {$total_to_pay}

Edited by lysybogu, 14 January 2016 - 09:28 PM.

Podarunkowo.pl - Prezenty, upominki



0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Cookies help us deliver our services. By using our services, you agree to use our cookies.     Learn more