Jump to content

Google Analytics with Prestashop on subdomain


AHW

Recommended Posts

Hi,

 

I was trying to search for similar issue, but could not find any results. If such question was answered in the past already, please just give me a link.

 

So anyway...

 

I have Prestashop installed in subdomain, let's say shop.example.com. I'm trying to get Google Analytics to work with all my subdomains. How should I do it? I have installed "gAnalytics" module, but there I give only ID. How can I say that shop.example.com is subdomain of example.com?

 

I know I can accomplish it with _gaq.push(['_setDomainName', 'conversion.pl']);, but after I have enabled gA module, I check my main page code and I see some strange code there. It uses:

 

ga('create', 'UA-47495700-1');

ga('send', 'pageview')

 

Looks bit different from what I should add...

 

What should I do, to have it work as expected. I'm preatty sure it's some simple and obvious...

 

Would appreciate any help,

AHW

Link to comment
Share on other sites

Thank you for your replay, but as I read it, I'm not sure whether I was perfectly clear with my description, or maybe just did not understand answer correctly. So anyway... let me precise and please let me know if that changes anything.

 

I do not want to track shop.example.com, but example.com, as I have some other subdomain (blog.example.com). So I want to have everything tracked under example.com (domain + 2 subdomains). If I set tracking ID the same for example.com and shop.example.com without "saying" somehow that example.com is leading one, I will have false results from tracking (one user visiting every subdomain will be treated as new user), as far I as I understand it correctly.

Link to comment
Share on other sites

then you can do as I do, I use the same UA-id for the related subdomains.

 

you can test if treated as new/visitor by doing this and looking at real-time monitor when navigating between domain and sub-domain.

 

And I think you explained very well but I may not have the 'other' answer you are looking for.  Typically it is best for this sort of question to be searched 'outside' of PrestaShop forum, i.e. google groups etc may have better advice.

Link to comment
Share on other sites

OK. I've done it like this (so maybe someone with similar issue can find it useful).

 

Just some note in first place: the code is with ga('create') etc. not _gaq.push because I've set in "gAnalytics" module "Universal Analytics Active" option to yes. In this case not ga.js is used but analytics.js (https://developers.google.com/analytics/devguides/collection/analyticsjs/).

 

Anyway, I've modified module's header.tpl and replaced original ga('create') line with:

ga('create', '{$ganalytics_id|escape:'htmlall':'UTF-8'}', 'auto');

 

(I'm not sure whether it's the best and cleanest way, but only one that comes to my mind)

 

According to documentation this 'auto' setting should automatically write cookies to highest possible domain (in my case, from shop.example.com to example.com) - hopefully! I've tried to do it manually with cookieDomain setting but every time it was set my page did not want to load at all (?).

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...