freakhouse Posted October 14, 2013 Share Posted October 14, 2013 Is there a way to add a different bit of javascript code to each product page? In order to use google's dynamic remarketing code you have to do this. The old remarketing code you could just put in the footer file, but this is different because it's more targeted. Any help would be appreciated. Link to comment Share on other sites More sharing options...
vekia Posted October 14, 2013 Share Posted October 14, 2013 you can do it in product editor page, just paste code there. but before you will do this, you must extend tinymce editor features and change validation function, everything is described here: full featured tinymce with java scripts on product edit page 1 Link to comment Share on other sites More sharing options...
freakhouse Posted October 14, 2013 Author Share Posted October 14, 2013 This worked, Big Thanks! Link to comment Share on other sites More sharing options...
moz Posted October 14, 2013 Share Posted October 14, 2013 (edited) hi, ok i had the same question ! So i did change the editor, but now, how can i manage to copy and paste my Js snippet for remarketing tag ? I have opened a product form page, but can"t manage with it . Edit : In fact i managed a little bit : <script type="text/javascript"> var google_tag_params = { ecomm_prodid: 'REPLACE_WITH_VALUE', ecomm_pagetype: 'REPLACE_WITH_VALUE', ecomm_totalvalue: 'REPLACE_WITH_VALUE' }; </script> But don't know how to integrate it to past the value from prestashop product page to this snippet.. Tks for your help.. Edited October 14, 2013 by moz (see edit history) Link to comment Share on other sites More sharing options...
freakhouse Posted October 14, 2013 Author Share Posted October 14, 2013 Hey moz- on the description section look on the far left below the scissors icon. There is an icon on the 3rd row to edit html source. paste your remarketing code below whatever description html coding is there. Link to comment Share on other sites More sharing options...
freakhouse Posted October 14, 2013 Author Share Posted October 14, 2013 if you need help with the replace with value stuff, let me know. I had to call in to google to figure that one out. Link to comment Share on other sites More sharing options...
moz Posted October 14, 2013 Share Posted October 14, 2013 (edited) hi, Yes ! i found it..Thanks a lot freakhouse! but my problem, maybe yours, is that the tinyeditor is adding some additonal code such as <![CDATA[ tag.. . <script type="text/javascript">// <![CDATA[ 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 = 998xxxxxx; var google_conversion_label = "EdbQCIyo3gUQxxxxxxxxx"; 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">// <![CDATA[ // ]]></script> <noscript>&amp;lt;div style="display:inline;"&amp;gt; &amp;lt;img height="1" width="1" style="border-style:none;" alt="" src="//googleads.g.doubleclick.net/pagead/viewthroughconversion/998xxxxxxx/?value=0&amp;amp;amp;label=EdbQCIxxxxxwM&amp;amp;amp;guid=ON&amp;amp;amp;script=0"/&amp;gt; &amp;lt;/div&amp;gt;</noscript> By the way, do i have to populate the product values for each page ? There is without any doubt a way to get it populate automatically ? isn't it ? Edited October 14, 2013 by moz (see edit history) Link to comment Share on other sites More sharing options...
freakhouse Posted October 14, 2013 Author Share Posted October 14, 2013 (edited) There is some extra code being added but it doesn't seem to make any difference. You can test your tag in Google Chrome with the Google Tag Assistant. Do a search for that on google and install it in Chrome. It will show you if your code is working correctly on your page. As far as adding the code on each page, it appears you are using the dynamic remarketing. That's what I'm doing. As opposed to just remarketing. With the dynamic you do have to add it to each page with the values replaced. id is your google product id. The type would be New if it's a new product. The value is entered for example '$99.95' All using the single quotes.With the plain remarketing code it could be added to just the footer.tpl file for example. That is different coding though I believe. Edited October 14, 2013 by freakhouse (see edit history) Link to comment Share on other sites More sharing options...
freakhouse Posted October 15, 2013 Author Share Posted October 15, 2013 Turns out I was wrong about the added code not making a difference. Apparently google doesn't like this. For example it starts adding // <![CDATA[ Google has an article where they say a lot of WYSIWYG editors do this. Any ideas on how to remove the extra coding that prestashop adds? Link to comment Share on other sites More sharing options...
moz Posted October 15, 2013 Share Posted October 15, 2013 (edited) Hi Freakhouse, I think that you have to bypass the tinymce editor , the the front end etc...Maybe through the productpage.tpl file directly ? I try to find a solution my side and keep you informed. Edited October 15, 2013 by moz (see edit history) Link to comment Share on other sites More sharing options...
freakhouse Posted October 15, 2013 Author Share Posted October 15, 2013 (edited) Moz- I realized after I wrote that last post that google only updates their remarketing page once a day, so my coding may have not been seen yet by google. Their page and its analysis was why i thought the extra code mattered. That and they have an article that states it must be exact. That article may be outdated. When I test it with the Chrome tag analyzer it says its fine and shows no errors. So getting rid of the extra coding may not be an issue after all. I will let you know when I find out for sure. Edited October 15, 2013 by freakhouse (see edit history) 1 Link to comment Share on other sites More sharing options...
vekia Posted October 15, 2013 Share Posted October 15, 2013 you don't have to worry about cdata A CDATA section is required if you need your document to parse as XML (e.g. when an XHTML page is interpreted as XML) and you want to be able to write literal i<10 and a && b instead of i<10and a && b, as XHTML will parse the JavaScript code as parsed character data as opposed to character data by default. This is not an issue with scripts that are stored in external source files, but for any inline JavaScript in XHTML you will probably want to use a CDATA section. Note that many XHTML pages were never intended to be parsed as XML in which case this will not be an issue. 1 Link to comment Share on other sites More sharing options...
moz Posted October 15, 2013 Share Posted October 15, 2013 (edited) Many thanks Freakhouse and vekia I need also to wait for a while..but i wonder regarding the method of implementing dynamic retargeting ..hardcoding or through tag manager or else .. 1/ The additional code on top of the google tag params have to be located just before the main core google snippet one let's saying like that. Ok if you handcode manually. 2/ But if you use the tag manager google platform, you have to also insert the google tag params named datalayer before the main code . The problem is that the container (which is inserted manually in the hearder.tpl file (template)) is just located at the beginning of the <body> tag, and if you proceed as you and i did (tagging just the google tag params addtional snippet in product page with wysiwyg editor) , you always find it after the container tag, so it's impossible to manage ! 3/ I can't find any way around the 2 above methods, as ready made modules seems to be quite rare for inserting external code in prestashop pages. Edited October 15, 2013 by moz (see edit history) Link to comment Share on other sites More sharing options...
freakhouse Posted October 16, 2013 Author Share Posted October 16, 2013 you don't have to worry about cdata Vekia- Currently my google account says my pages are missing custom parameters. These parameters are on my pages, so google's spiders are not seeing them. Is there a way to get around prestashop adding this code? In order to troubleshoot this I need be able to add the exact code google gave me and not have it modified. Link to comment Share on other sites More sharing options...
vekia Posted October 16, 2013 Share Posted October 16, 2013 you can try to add it manually in header.tpl file with {literal}YOUR_CODE_HERE{/literal} tags Link to comment Share on other sites More sharing options...
freakhouse Posted October 16, 2013 Author Share Posted October 16, 2013 I have different code on each product page. For example, on product #1 page, the code is something like prod_id=1, product #2 page the code is prod_id=2, etc. The header.tpl file would change it on every page to the same thing, right? That wouldn't solve my problem. Link to comment Share on other sites More sharing options...
freakhouse Posted October 17, 2013 Author Share Posted October 17, 2013 (edited) I tried using the literal tags in my product description. They don't do anything. The CDATA coding is still generated and my variables are made useless. Got any more ideas? Edited October 17, 2013 by freakhouse (see edit history) Link to comment Share on other sites More sharing options...
moz Posted October 17, 2013 Share Posted October 17, 2013 (edited) Freakhouse, It's always the same problem when inserting external scripts for pushing variables (productId etc..) to external server (here google analytics ones) You have to develop an intermediary logic php code which set the prestashop variables for populating them automatically to the javascript google analytics Modifying the tpl is useful for still code, not for dynamic one.. That's the main use of modules ! But i can't find any for that purpose... Edited October 17, 2013 by moz (see edit history) Link to comment Share on other sites More sharing options...
moz Posted October 17, 2013 Share Posted October 17, 2013 Freakhouse, Depends on your objectives, if you want, i can help you finding the right developper to handle properly this matter. Link to comment Share on other sites More sharing options...
vekia Posted October 17, 2013 Share Posted October 17, 2013 and what about {Tools::getValue('product_id')} or some if conditions etc. ? i think that in this case modification of php logic isn't necessary. Link to comment Share on other sites More sharing options...
freakhouse Posted October 17, 2013 Author Share Posted October 17, 2013 (edited) Vekia- I feel like my question got missed. The CDATA is basically remarking out the google code I've inserted. Surely there has to be a way to get around this? For example: <script type="text/javascript">var google_tag_params = {ecomm_prodid: 'RLMUS8',ecomm_pagetype: 'New',ecomm_totalvalue: '88.00',};</script> gets turned into this by Prestashop: <script type="text/javascript">// <![CDATA[var google_tag_params = {ecomm_prodid: 'RLMUS8',ecomm_pagetype: 'New',ecomm_totalvalue: '88.00',};// ]]></script> So, anything between // <![CDATA[ and // ]]> is basically invisible to a spider. Edited October 17, 2013 by freakhouse (see edit history) Link to comment Share on other sites More sharing options...
moz Posted October 18, 2013 Share Posted October 18, 2013 hi vekia, For newbies, Could you please go further deep in your explanation..and give us the context of your idea of {Tools::getValue('product_id')} .. Many tks in advance Link to comment Share on other sites More sharing options...
vekia Posted October 18, 2013 Share Posted October 18, 2013 before i will start please let me know what exactly you want achieve and what code you want to use, and where you want to use product ID number Link to comment Share on other sites More sharing options...
freakhouse Posted October 18, 2013 Author Share Posted October 18, 2013 Vekia- did you see my question above about the CDATA making the google java code not work? Link to comment Share on other sites More sharing options...
vekia Posted October 18, 2013 Share Posted October 18, 2013 ohh but i don't know what's going on here. a little chaotic conversation. let's clarify. freakhouseYou pasting this code to product page editor (for example to description field)then tinymce changing it automatically with CDATA.now you think that this code doesnt work because of this, right?you want to remove CDATA tags from code.am i right? mozand you, what you exactly expect? Link to comment Share on other sites More sharing options...
freakhouse Posted October 19, 2013 Author Share Posted October 19, 2013 Vekia- yes, that is want I want to do. Link to comment Share on other sites More sharing options...
vekia Posted October 19, 2013 Share Posted October 19, 2013 so in your case it will be a bit hard to remove these code mainly because tinymce editor add CDATA automatically. here is a little workaround. open product.tpl search for $product->description and change it to: {$product->description|replace:'// <![CDATA[':''|replace:'// ]]>':''} Link to comment Share on other sites More sharing options...
freakhouse Posted October 20, 2013 Author Share Posted October 20, 2013 Vekia- I don't understand. I looked in product.tpl There are many instances of the phrase $product->description which one am I replacing? Link to comment Share on other sites More sharing options...
vekia Posted October 20, 2013 Share Posted October 20, 2013 ok, so my question now is: where you inserted google code? to short description? or to normal description? Link to comment Share on other sites More sharing options...
freakhouse Posted October 21, 2013 Author Share Posted October 21, 2013 Vekia- normal (long) description. Link to comment Share on other sites More sharing options...
vekia Posted October 21, 2013 Share Posted October 21, 2013 so you have to change it here: {if isset($product) && $product->description} <!-- full description --> <div id="idTab1" class="rte">{$product->description}</div> {/if} by default it's near 504 line in product.tpl file Link to comment Share on other sites More sharing options...
freakhouse Posted October 21, 2013 Author Share Posted October 21, 2013 Hi Vekia- I am not seeing those exact lines in my file product.tpl file The forum won't let me attach that kind of file. Could I email it to you and you modify it for me? It would probably be a lot quicker than trying to explain it to me Maybe you could PM your email? Link to comment Share on other sites More sharing options...
vekia Posted October 21, 2013 Share Posted October 21, 2013 it will be much easier and also helpful for other merchants (or devs) here if oyu will share it on http://pastebin.com/ Link to comment Share on other sites More sharing options...
freakhouse Posted October 21, 2013 Author Share Posted October 21, 2013 Vekia- Cool site. Here you go: http://pastebin.com/bnL2iBae Link to comment Share on other sites More sharing options...
moz Posted October 21, 2013 Share Posted October 21, 2013 Hi Vekia, Look for a way to insert a portion of script (remarketing tag) to retrieve variables from the above many times mentioned product page I 'am a bit lost i'm afraid, try to find my way out with a bit of help from a developper (not very available for now) . As soon as i manage , i 'll keep informed the forum. Hi Freakhouse, So did you succeed in pushing dynamically those variables to adwords ? Link to comment Share on other sites More sharing options...
vekia Posted October 21, 2013 Share Posted October 21, 2013 Vekia- Cool site. Here you go: http://pastebin.com/bnL2iBae here it is: {if $product->description} <section class="page_product_box toggle_frame more_info_inner"> <h3 class="toggle">{l s='More info'}<i class="icon-toggle icon-minus-sign-alt"></i></h3> {if isset($product) && $product->description} <div class="toggle_content"> {$product->description} </div> {/if} </section> {/if} Link to comment Share on other sites More sharing options...
freakhouse Posted October 21, 2013 Author Share Posted October 21, 2013 Hi Vekia- so every where in that code you just posted that it says $product->description I should replace with the code you gave me before: {$product->description|replace:'// <![CDATA[':''|replace:'// ]]>':''} is that right? Link to comment Share on other sites More sharing options...
vekia Posted October 21, 2013 Share Posted October 21, 2013 that's correct Link to comment Share on other sites More sharing options...
freakhouse Posted October 21, 2013 Author Share Posted October 21, 2013 tried it out- it's still adding the extra CDATA code in. Link to comment Share on other sites More sharing options...
vekia Posted October 21, 2013 Share Posted October 21, 2013 you've got force compile turned on? Link to comment Share on other sites More sharing options...
freakhouse Posted October 21, 2013 Author Share Posted October 21, 2013 don't know - where is that? Link to comment Share on other sites More sharing options...
freakhouse Posted October 21, 2013 Author Share Posted October 21, 2013 I found it and turned it on, that didn't fix the problem. Link to comment Share on other sites More sharing options...
freakhouse Posted October 21, 2013 Author Share Posted October 21, 2013 I looked at the source code for one of my pages. It is showing correctly there, but not on my editing page which is why I didn't see it before. That should be good enough. Thanks Vekia! Link to comment Share on other sites More sharing options...
vekia Posted October 23, 2013 Share Posted October 23, 2013 so cdata disappears ? Link to comment Share on other sites More sharing options...
freakhouse Posted October 23, 2013 Author Share Posted October 23, 2013 Vekia- Yes it does. Thanks again. Link to comment Share on other sites More sharing options...
freakhouse Posted October 24, 2013 Author Share Posted October 24, 2013 Vekia- Google spiders visited my page and didn't see their code. I look at it more closely and realized your coding is removing some of their code as well. I'm pasting their code below. Your code removes their CDATA as well as the stuff that prestashop generates. RLMUS13, Product, 88.00 are values for my specific product page. These are the only things that are different between each page I use this on. <script type="text/javascript">var google_tag_params = {ecomm_prodid: 'RLMUS13',ecomm_pagetype: 'Product',ecomm_totalvalue: '88.00',};</script><script type="text/javascript">/* <![CDATA[ */var google_conversion_id = 1069103396;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/1069103396/?value=0&guid=ON&script=0"/></div></noscript> Link to comment Share on other sites More sharing options...
freakhouse Posted October 24, 2013 Author Share Posted October 24, 2013 Would getting HTML box pro solve this issue? Link to comment Share on other sites More sharing options...
vekia Posted October 24, 2013 Share Posted October 24, 2013 so code provided by google has got cdata tags, so we can't remove it! where i can verify this code? how you checking if code is valid for google or not? i will test it in html box pro, it should work, but before i need to check it to be 100% sure Link to comment Share on other sites More sharing options...
freakhouse Posted October 24, 2013 Author Share Posted October 24, 2013 In my Google Adwords account it is saying it doesn't see any tags now on any of my pages. Specifically, where I am getting this limited info is in their Remarketing section. That is what this code is for: remarketing. I have tested with Chrome's Tag Assistant and it said it was ok even before I added your coding, so I wouldn't use that as a point of reference. I have asked Google and they have never given me an answer. It seems that you have to include their code exactly as they give it to you. Vekia, If you want to log in to my google adwords account and see what I am seeing, PM me and I will give you the login details. According to the remarketing section in my Google adwords account, before I added your code it was seeing the tags, but not the section with the "user variables". In other words my product id, product type, and value that I mentioned in a previous post. There is also a time lag, where you have to wait at least 24 hours for them to update this section. I waited a couple days and that's when I realized google wasn't seeing the tags. Here is a page I have the code on for example: http://redlinemusicgear.com/guitar-and-bass-pedals/68-little-dual-sgos-4260142210019.html Link to comment Share on other sites More sharing options...
freakhouse Posted October 25, 2013 Author Share Posted October 25, 2013 Vekia- did you see my last post? Link to comment Share on other sites More sharing options...
vekia Posted October 25, 2013 Share Posted October 25, 2013 yes i saw it, i checked your website and i see this code there, i don't know why google doesn't accept it Link to comment Share on other sites More sharing options...
freakhouse Posted October 25, 2013 Author Share Posted October 25, 2013 I just got off the phone with google. Their support team has pretty limited information about this "dynamic remarketing" code. They told me the code was ok, but I need to put code on every page of my site for it all to work correctly. I am going to do this and I will let you know. Their system is really slow to update and check as well. It sees the product codes now, but not the page type and prices. Also, they said some browsers won't see the code the way it is, but most will. Link to comment Share on other sites More sharing options...
Mackens Posted November 5, 2013 Share Posted November 5, 2013 Hi, is your discussion about adding this code to each prestashop page ? https://developers.google.com/tag-manager/quickstart Link to comment Share on other sites More sharing options...
moz Posted December 10, 2013 Share Posted December 10, 2013 Hi, I found the solution, in fact, you can use the footer template product page (footer.tpl) to insert your snippet for adwords remarketiing : here : https://www.fr.adwords-community.com/t5/Configuration-et-principes-de/Balises-remarketing-pour-Prestashop/m-p/27434/highlight/true#M2886 But the problem is that maybe the script will slow down the loading time of the page.. @freakhouse : how did you manage finally , with which kind of coding ? Link to comment Share on other sites More sharing options...
ms99 Posted September 19, 2014 Share Posted September 19, 2014 Can be changed in the product page, the process moves to the next page so that instead of Javascript loaded the next page on the new? Link to comment Share on other sites More sharing options...
vijaykryadav24 Posted May 22, 2015 Share Posted May 22, 2015 (edited) Hi vekia, How to add external Js to product_list.tpl ? product_list.tpl file is located at themes/default-bootstrap/ ProductController.php file is locatied at override/classes/controller/ eko-image-rollover.js file located at \themes\default-bootstrap\js I tried this one ,but its not working for me prestashop version 1.6 class ProductController extends ProductControllerCore { { public function setMedia() { parent::setMedia(); // CSS files Tools::addJS(_THEME_JS_DIR_.'eko-image-rollover.js'); } } Thanks Edited May 22, 2015 by vijaykryadav24 (see edit history) Link to comment Share on other sites More sharing options...
robyroy Posted June 11, 2016 Share Posted June 11, 2016 quoto... version1.6 Link to comment Share on other sites More sharing options...
Joey Posted August 16, 2018 Share Posted August 16, 2018 For PS1.7.3 version, do I still need turn on the "extend tinymce editor features" for insert the "google's dynamic remarketing code"? Or just paste the code to product summary / description / embed code in the product page as I want insert one google tags js snippet code in one target product, not for all products. Thanks! code look like below: <!-- Start of global snippet: Please do not remove Place this snippet between the <head> and </head> tags on every page of your site. --> <!-- Global site tag (gtag.js) - DoubleClick --> <script async src="https://www.googletagmanager.com/gtag/js?id=XX-xxxxxx"></script> <script> window.dataLayer = window.dataLayer || []; function gtag(){dataLayer.push(arguments);} gtag('js', new Date()); gtag('config', 'XX-xxxxxx'); </script> <!-- End of global snippet: Please do not remove --> 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