cactusman2 Posted April 20, 2013 Share Posted April 20, 2013 By default Google Analytics is not integrated to the mobile version even if the GG Analytics module is activated in the back office. Also simply add the Google Analytics code on the template file header.tpl won't work because the mobile theme use mobile jQuery. However there is a solution to adapt the GG Analytics code to mobile jQuery explained here: http://www.jongales....-jquery-mobile/ So in order to add Google Analytics to the mobile theme... - in themes/prestashop_mobile/header.tpl just before </head> add {literal} <script type="text/javascript"> var _gaq = _gaq || []; (function() { var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js'; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s); })(); </script> {/literal} - in themes/prestashop_mobile/footer.tpl just before </body> add {literal} <script type="text/javascript"> $('[data-role=page]').live('pageshow', function (event, ui) { try { _gaq.push(['_setAccount', 'YOUR GG ANALYTICS ID']); hash = location.hash; if (hash) { _gaq.push(['_trackPageview', hash.substr(1)]); } else { _gaq.push(['_trackPageview']); } } catch(err) { } }); </script> {/literal} Remember to replace YOUR GG ANALYTICS ID by your Google Analytics id! 2 Link to comment Share on other sites More sharing options...
PascalVG Posted April 21, 2013 Share Posted April 21, 2013 Hi Cactusman2, Thanks for sharing! Thanks for taking the time to educate us. :-) Pascal Link to comment Share on other sites More sharing options...
petete2008 Posted May 14, 2013 Share Posted May 14, 2013 (edited) Thanks for sharing!! This change is only for visits. What changes must be made to order transactions are recorded in analytics? Or not necessary because already hooked into the {$ hook_order_confirmation}? Edited May 14, 2013 by petete2008 (see edit history) Link to comment Share on other sites More sharing options...
cactusman2 Posted May 14, 2013 Author Share Posted May 14, 2013 With Paypal it should work as the file themes/prestashop_mobile/modules/paypal/views/templates/front/order-confirmation.tpl is there. However for other payment modules you will have to add the confirmation template file to the mobile theme. Note that if a customer does not come back to the website after the payment is completed the order won't be counted in GA. This problem is for both normal version and mobile version. I have this problem with the 2Checkout module. What I did is set up a custom report counting unique visitors arriving to the payment page. It's pretty accurate as not many customers stop the order process at this step. Link to comment Share on other sites More sharing options...
petete2008 Posted May 14, 2013 Share Posted May 14, 2013 thanks for the help. I understand what you say Link to comment Share on other sites More sharing options...
jujutte24 Posted June 14, 2013 Share Posted June 14, 2013 Hi, i've try this solution, but i don't work... is it ok for you ? Link to comment Share on other sites More sharing options...
cactusman2 Posted June 14, 2013 Author Share Posted June 14, 2013 Hi Jujutte, Could you give me the url of your shop? Regards, Loïc Link to comment Share on other sites More sharing options...
jujutte24 Posted June 15, 2013 Share Posted June 15, 2013 May be it's a problem with jQuery mobile and the Javascript fonction ? Link to comment Share on other sites More sharing options...
cactusman2 Posted June 15, 2013 Author Share Posted June 15, 2013 Hi, I don't see the code I gave in to your mobile version. Did you clear the smarty cache? If not go the folder tools/smarty/compile and delete everything except the file index.php 1 Link to comment Share on other sites More sharing options...
jujutte24 Posted June 15, 2013 Share Posted June 15, 2013 it's done now Link to comment Share on other sites More sharing options...
cactusman2 Posted June 16, 2013 Author Share Posted June 16, 2013 It should work now Link to comment Share on other sites More sharing options...
jujutte24 Posted June 19, 2013 Share Posted June 19, 2013 Yes, it work now !! Thank you so much Link to comment Share on other sites More sharing options...
Recommended Posts