Lahun Lamat Posted December 3, 2021 Share Posted December 3, 2021 Hello, I need to insert the following pinterest event code, could somebody help me where to do that: <script> pintrk('track', 'addtocart', { value: 100, order_quantity: 1, currency: 'MXN' }); </script> <script> pintrk('track', 'checkout', { value: 100, order_quantity: 1, currency: 'MXN' }); </script> I'm using foundation skin my site: https://www.bellerebelle.com.mx I will appreciate any help Regars Link to comment Share on other sites More sharing options...
bsmither Posted December 5, 2021 Share Posted December 5, 2021 I do not know anything about Pinterest, but from the arguments of the function call to pintrk(), I assume you want this function call to happen only when the customer adds something to the cart, and only when the customer starts the checkout process. Is this assumption correct? Link to comment Share on other sites More sharing options...
Lahun Lamat Posted December 8, 2021 Author Share Posted December 8, 2021 On 12/5/2021 at 4:41 PM, bsmither said: I do not know anything about Pinterest, but from the arguments of the function call to pintrk(), I assume you want this function call to happen only when the customer adds something to the cart, and only when the customer starts the checkout process. Is this assumption correct? That is correct! Link to comment Share on other sites More sharing options...
bsmither Posted December 9, 2021 Share Posted December 9, 2021 We will edit the template file element.js_foot.php. At the bottom, add this: <script>{literal}pintrk('track','checkout',{value:100,order_quantity:1,currency:'MXN'});{/literal}</script> This edit will put the above bit of javascript on every page, including during the checkout process. However, if you do not want this javascript to execute on every page of the checkout process, we can add some template code to only put this javascript code on the page where "_a=checkout", as opposed to "basket", "confirm", "gateway", and "complete". {if $smarty.get._a eq "checkout"}<script>{literal}pintrk('track','checkout',{value:100,order_quantity:1,currency:'MXN'});{/literal}</script>{/if} There is a problem, however. CubeCart most always uses an AJAX request to add an item to the cart. So, even if we put the 'addtocart' script in the HTML code that gets returned to that AJAX request, it won't get executed. As best I can determine, the proper way is to find the javascript that manages that AJAX request, and put this 'addtocart' script inside the "complete" block of the AJAX call. See 2.cubecart.js, near line 523. Link to comment Share on other sites More sharing options...
Lahun Lamat Posted December 9, 2021 Author Share Posted December 9, 2021 39 minutes ago, bsmither said: We will edit the template file element.js_foot.php. At the bottom, add this: <script>{literal}pintrk('track','checkout',{value:100,order_quantity:1,currency:'MXN'});{/literal}</script> This edit will put the above bit of javascript on every page, including during the checkout process. However, if you do not want this javascript to execute on every page of the checkout process, we can add some template code to only put this javascript code on the page where "_a=checkout", as opposed to "basket", "confirm", "gateway", and "complete". {if $smarty.get._a eq "checkout"}<script>{literal}pintrk('track','checkout',{value:100,order_quantity:1,currency:'MXN'});{/literal}</script>{/if} There is a problem, however. CubeCart most always uses an AJAX request to add an item to the cart. So, even if we put the 'addtpcart' script in the HTML code that gets returned to that AJAX request, it won't get executed. As best I can determine, the proper way is to find the javascript that manages that AJAX request, and put this 'addtocart' script inside the "complete" block of the AJAX call. See 2.cubecart.js, near line 523. Thank you bmither, I will try implement your recomendations. Best Regards Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.