Jump to content

remarketing Google prestashop 1.5


Recommended 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&guid=ON&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 !!!

  • Like 5
Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...

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

Link to comment
Share on other sites

  • 2 weeks later...
  • 1 month later...

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

Link to comment
Share on other sites

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 (see edit history)
Link to comment
Share on other sites

  • 2 months later...
  • 6 months later...

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 (see edit history)
Link to comment
Share on other sites

  • 1 month later...

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

  • Like 1
Link to comment
Share on other sites

  • 3 months later...

Guys, whether you are using our module (http://addons.prestashop.com/en/advertising-marketing-newsletter-modules/9736-google-remarketing-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 !

Link to comment
Share on other sites

  • 2 months later...

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!

  • Like 2
Link to comment
Share on other sites

  • 4 weeks later...
  • 1 month later...

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?

Link to comment
Share on other sites

Hello, Thanks for the useful information. I can confirm that I almost have this working, However im having a slight issue with the following

 

  • google tag assistant reports "some products are not valid"

 

  • google adwords is telling me the following;

 

Values for "ecomm_prodid" should match item identifiers in your Merchant Center feed.
The value of the "ecomm_prodid" parameter being passed to the remarketing tag is incorrect. Your tag's "ecomm_prodid" value needs to match either the "id" or "item_group_id" of the product in the connected Google Merchant Center account

 

 
  • My Merchant feed "Item Id" is as follows; 101-en, 102-en, 103-en, 104-en, 105-en..... and so on..
 
  • when I check the tag assistant the custom parameter reports "ecomm_prodid": "101",
 
I believe the script is communicating just the product id number and not the -en part?? any idea how I can work around this?
Link to comment
Share on other sites

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}

 

Thank you lysybogu, it works perfectly now :-)

Link to comment
Share on other sites

 

Hello, Thanks for the useful information. I can confirm that I almost have this working, However im having a slight issue with the following

 

  • google tag assistant reports "some products are not valid"

 

  • google adwords is telling me the following;

 

Values for "ecomm_prodid" should match item identifiers in your Merchant Center feed.
The value of the "ecomm_prodid" parameter being passed to the remarketing tag is incorrect. Your tag's "ecomm_prodid" value needs to match either the "id" or "item_group_id" of the product in the connected Google Merchant Center account

 

 
  • My Merchant feed "Item Id" is as follows; 101-en, 102-en, 103-en, 104-en, 105-en..... and so on..
 
  • when I check the tag assistant the custom parameter reports "ecomm_prodid": "101",
 
I believe the script is communicating just the product id number and not the -en part?? any idea how I can work around this?

 

 

 

hello ajnglagla, Can you or anyone else confirm how to do this?... its the solution im looking for in my above post  :)

 

SOLVED!: Simply add the country code as follows in bold;

 

ecomm_prodid: '{$product->id}-en',

{elseif $page_name == 'product'}ecomm_prodid: '{$product->id}-en',
ecomm_pagetype: 'product',
ecomm_totalvalue: {$product->getPrice(true, $smarty.const.NULL, $priceDisplayPrecision)}
Link to comment
Share on other sites

  • 4 months later...

Here is my custom code which caculate with the VAT :

<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: {$cart->getOrderTotal(true)}
{elseif $page_name == 'cart'}
    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: {$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 == 'category'}
    ecomm_pagetype: 'category'
{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: {$cart->getOrderTotal(true)}
{elseif $page_name == 'order-confirmation'}
    ecomm_prodid: [{foreach from=$products item=product name=prodid}'{$product.id_product}'{if $smarty.foreach.prodid.last}{else},{/if}{/foreach}],
    ecomm_pagetype: 'purchase',
    ecomm_totalvalue: {$cart->getOrderTotal(true)}
{else}
    ecomm_pagetype: 'other'
{/if}
};

</script>
  • Like 1
Link to comment
Share on other sites

×
×
  • Create New...