Nakatika Posted August 23, 2017 Share Posted August 23, 2017 Hello, I already installed base code of FB pixel to header.tpl and it works fine. But where exactly in prestashop I should install the following event codes? Search Add to Cart View Content Complete Registration 1 Link to comment Share on other sites More sharing options...
prestahero.com Posted August 24, 2017 Share Posted August 24, 2017 Hello, I already installed base code of FB pixel to header.tpl and it works fine. But where exactly in prestashop I should install the following event codes? Search Add to Cart View Content Complete Registration you only need to add it to header.tpl file, that's enough. (make sure you put the code in side {litteral} YOUR CODE {/litteral} to avoid smarty syntax error Link to comment Share on other sites More sharing options...
Nakatika Posted August 26, 2017 Author Share Posted August 26, 2017 you only need to add it to header.tpl file, that's enough. (make sure you put the code in side {litteral} YOUR CODE {/litteral} to avoid smarty syntax error Are you sure? How facebook will recognize when customers click "add to cart", if code will be in header.tpl ? Link to comment Share on other sites More sharing options...
Nakatika Posted August 28, 2017 Author Share Posted August 28, 2017 One more question. I think FB do not recognize add to cart action, maybe I should add something in conversion value? Link to comment Share on other sites More sharing options...
vekia Posted August 28, 2017 Share Posted August 28, 2017 'add to cart' event is usually a dynamic event, it is not enough to just copy-paste the event code. Case requires additional code to support dynamic events - to spawn add to cart event only when someone will add product to cart - simple page view is not equal to "add to cart" prcess and this is what you're trying to achieve. 1 Link to comment Share on other sites More sharing options...
Nakatika Posted August 29, 2017 Author Share Posted August 29, 2017 'add to cart' event is usually a dynamic event, it is not enough to just copy-paste the event code. Case requires additional code to support dynamic events - to spawn add to cart event only when someone will add product to cart - simple page view is not equal to "add to cart" prcess and this is what you're trying to achieve. Thank you. What I want is to return customers, when they click on the product in my e-shop. How to make this product shown in facebook for customer which viewed it on my website? For the moment I paste this event in product.tpl : {literal} <script> fbq('track', 'ViewContent', { content_ids: ['100','200'], content_type: 'product', value: 40.25, currency: 'EUR' }); </script> {/literal} 1 Link to comment Share on other sites More sharing options...
Scully Posted August 29, 2017 Share Posted August 29, 2017 With this code you will always have the same values tracked - in my humble opinion this doesn't help you at all. But anyway - one more website sending data to our facebook - friends. Thanks for that. Link to comment Share on other sites More sharing options...
Nakatika Posted August 29, 2017 Author Share Posted August 29, 2017 With this code you will always have the same values tracked - in my humble opinion this doesn't help you at all. But anyway - one more website sending data to our facebook - friends. Thanks for that. Sorry, I misunderstand. Could you explain more detailed, how can I solve this problem? Link to comment Share on other sites More sharing options...
Scully Posted August 29, 2017 Share Posted August 29, 2017 (edited) if you use this as hardcoded javascript.... value: 40.25, currency: 'EUR' ... what would you then expect facebook gets as amount and as currency? Yes, always 40.25 Euros for every tracking which takes place. Is this intention? Always 40.25 EUR? In my opinion and from a technical view, it doesn't make sense at all to put any amount into product.tpl because at this time it is not related to a cart or order. P.S. Most shop owners don't spend a second to think over what amounts of data they send to Facebook, Google & Co. The just send all data. Most of them do also not realize that it's this big companys benefit getting this data. And what is the benefit for the shop owner. Does he/she have a benefit? What you you get for sending them data? Ok, but that is off topic. Sorry for that. Edited August 29, 2017 by Scully (see edit history) Link to comment Share on other sites More sharing options...
Nakatika Posted August 29, 2017 Author Share Posted August 29, 2017 if you use this as hardcoded javascript.... value: 40.25, currency: 'EUR' ... what would you then expect facebook gets as amount and as currency? Yes, always 40.25 Euros for every tracking which takes place. Is this intention? Always 40.25 EUR? In my opinion and from a technical view, it doesn't make sense at all to put any amount into product.tpl because at this time it is not related to a cart or order. P.S. Most shop owners don't spend a second to think over what amounts of data they send to Facebook, Google & Co. The just send all data. Most of them do also not realize that it's this big companys benefit getting this data. And what is the benefit for the shop owner. Does he/she have a benefit? What you you get for sending them data? Ok, but that is off topic. Sorry for that. Thank you. I just want to return customers, when they click on the product in my e-shop. So where and which event I should add to my presta? Link to comment Share on other sites More sharing options...
BonPresta Posted August 29, 2017 Share Posted August 29, 2017 (edited) Thank you. What I want is to return customers, when they click on the product in my e-shop. How to make this product shown in facebook for customer which viewed it on my website? For the moment I paste this event in product.tpl : {literal} <script> fbq('track', 'ViewContent', { content_ids: ['100','200'], content_type: 'product', value: 40.25, currency: 'EUR' }); </script> {/literal} it's hard to add facebook pixel without integrating a new module I can give an example of creating a module Сode function for class module public function hookDisplayHeader() { if (!$this->isCached('facebookpixel-header.tpl', $this->getCacheId())) { if ($this->context->controller->php_self == 'product') { $facebookpixel_product = $this->context->controller->getProduct(); $currency = new Currency($this->context->cookie->id_currency); $this->context->smarty->assign( array( 'facebookpixel_product' => $facebookpixel_product, 'facebookpixel_currency' => $currency->iso_code ) ); } if ($this->context->controller->php_self == 'order') { $currency = new Currency($this->context->cookie->id_currency); $facebookpixel_total_price = $this->context->cart->getOrderTotal(true, Cart::BOTH); $this->context->smarty->assign( array( 'facebookpixel_total_price' => $facebookpixel_total_price, 'facebookpixel_currency' => $currency->iso_code ) ); } $this->context->smarty->assign( array( 'page_name_pixel' => $this->context->controller->php_self, ) ); $currency = new Currency($this->context->cookie->id_currency); $this->context->smarty->assign( array( 'facebookpixel_currency' => $currency->iso_code ) ); $this->context->cart->getOrderTotal(true, Cart::BOTH); $this->context->smarty->assign('config', $this->getSmartyConfigurations()); } return $this->display($this->_path, '/views/templates/hook/facebookpixel-header.tpl', $this->getCacheId()); } Сode front - ViewContent and AddToCart {if $page_name_pixel == 'product'} <script type="text/javascript"> {literal} fbq('track', 'ViewContent', { content_name: '{/literal}{$facebookpixel_product->name|escape:'htmlall':'UTF-8'}{literal}', value: {/literal}{$facebookpixel_product->price|string_format:'%.2f'|escape:'htmlall':'UTF-8'}{literal}, currency: '{/literal}{$facebookpixel_currency|escape:'htmlall':'UTF-8'}{literal}' }); var id_product_fb = {/literal}{$facebookpixel_product->id|escape:'htmlall':'UTF-8'}{literal} $('#add_to_cart, .ajax_add_to_cart_button').live('click', function(){ fbq('track', 'AddToCart', { content_name: '{/literal}{$facebookpixel_product->name|escape:'htmlall':'UTF-8'}{literal}', content_ids: [id_product_fb], content_type: 'product', currency: '{/literal}{$facebookpixel_currency|escape:'htmlall':'UTF-8'}{literal}' }); }); {/literal} </script> {/if} Сode front - InitiateCheckout {if $page_name_pixel == 'order'} <script type="text/javascript"> {literal} fbq('track', 'InitiateCheckout', { value: {/literal}{$facebookpixel_total_price|escape:'htmlall':'UTF-8'}{literal}, currency: '{/literal}{$facebookpixel_currency|escape:'htmlall':'UTF-8'}{literal}', content_name: 'Checkout', }); {/literal} </script> {/if} Edited August 29, 2017 by BonPresta (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now