Closed (fixed)
Project:
Domain
Version:
6.x-2.0-rc6
Component:
Code
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
8 Apr 2008 at 03:22 UTC
Updated:
19 Oct 2011 at 22:53 UTC
Hi,
I just heard about Domain Access and I think about a new feature regarding analytics. Is there a way that on each domain generated by Domain Access a new analytics account could be used. Just like Domain Menu wherein each domain could have different primary and secondary menus.
Thanks a lot.
Comments
Comment #1
hass commentedI don't know "Domain Access", but isn't it a multi-site logic? By this way it already works this way.
Comment #2
hass commentedMoving this to Domain Access module. What you are requesting here is allow switching of "googleanalytics_account" variable value.
I know there is a possible workaround in GA with custom JS code that switch the ga account number based on domain name. On the other side you could overwrite this variable via settings.php, but i think the Domain Access module should do this variable switching for you like "Localizer" or "i18n".
I see Domain Access only as a hack and I'm sure - if you cannot develop modules and themes yourself, this is the wrong module for you. The Domain Access maintainers should support you here, but the GA module is not going to implement core hacks.
Comment #3
hass commentedComment #4
nonsieYou can achieve this by using hook_domainconf. There's more on it here: http://drupal.org/node/242453. I added this to one of my sites and it works without any problems.
Comment #5
agentrickardnonsie is correct. hook_domainconf() supports this integration. It can either be added to the Google Analytics module, or included inside a custom domain_conf.inc file.
Since this is not a core Drupal feature, I will not be adding it to the Domain Access release directly.
See http://therickards.com/api/function/hook_domainconf/Domain
Comment #6
amariotti commentedThis info is all great, but it would be nice to see exactly what the function should look like for the Google Analytics Accounts to work on different domains independently. Does someone have the function that can be posted here. With analytics becoming so popular something like this could be very beneficial to have documented somewhere permanently. Thanks!
Comment #7
nonsieActually if you just need statistics by subdomain you can use a single Google Analytics account and use Google Analytics advanced segments. That's the route we decided to go.
Comment #8
amariotti commentedGood to know! Thanks.
Comment #9
jamesfk commentedHi amariotti,
I got this to work with the following code in domain_conf.inc as my clients wanted separate accounts for each of their domains - good luck!
Comment #10
agentrickardThe solution in #9 is the correct implementation of the API. (Though I would change 'account' to 'google_analytics' in the $form arrays.) This should work for D5 or D6.
Nice work.
Comment #11
amariotti commentedWow jamesfk, thanks so much! I will give this a shot once I get SMB access to my webserver again.
Comment #12
amariotti commentedWell, I added the code above to my domain_conf.inc file in /sites/all/modules/domain/domain_conf. Is that where I should be adding that file? I made the changes suggested in #10 and here's what mine looks like.
After I did this it still retains the changes that I make on any of my domains. What am I missing here?
Comment #13
agentrickardYour function is named incorrectly. My comment was a bit vague, I guess.
Comment #14
amariotti commentedThanks agentrickard!
Comment #15
amariotti commentedSo... now I'm seeing the Analytics Code field on my Domain Settings page but it's not actually working. I changed the account number on one of my domains and went and loaded the page and viewed the source and it's still showing the Account Code for the primary domain. What gives?
Comment #16
agentrickardDid you follow the instructions for installing Domain Conf?
Are you viewing cached pages?
Comment #17
agentrickardBump status on active issues, please.
Comment #18
amariotti commentedI just took another look at this again this morning and after uninstalling the Google Analytics Module and re-installing it now the analytics code snippet doesn't show up at all on any of my pages. When I go to Site Configuration it shows the "UA-" which proves to me that without a code in there the module doesn't work in the first place. Can anybody shed any more light on this? This is really weird.
Comment #19
nonsieJust my 2 cents - I was doing it on 6.x version a while back (using custom snippet in domain_conf). However after we decided the scrap this feature the variables created by the snippet were still in the db and getting loaded on pages even though we had changed it to a single GA account.
So, when you uninstall Google Analytics make sure you remove all variables in the db, not just for the default domain. If nothing else it will make debugging easier.
Comment #20
amariotti commentedThanks for the advice nonsie. When I uninstalled the module and reinstalled it I went back to the Site Config page to see if it was empty and it was. There's something that I'm missing here... arg...
agentrickard, I just read through the installation stuff on the rc5 and it is installed correctly. And I also cleared my cache on Safari to see if that was my problem and still the same result. Is this working for everyone else?
Comment #21
amariotti commentedFixing what I messed up.
Comment #22
agentrickardDo the keys that you save using Domain Conf get stored and shown back on the domain configuration form? These are stored in the {domain_conf} table and loaded per domain. If empty, the domain should use the site default.
Comment #23
batigolixcreating segments in google analytics is a far better solution than making changes to the module
Comment #24
amariotti commented#22: Yes, the GA key does get saved to the domain configuration page.
#23: While it might be a better solution for one person, it might not be for another. I'd like to keep my accounts separate to make reporting much easier. My main concern was to keep the secondary sites away from the main site. Not a huge deal, but it is the way I'd like it to be configured, and it sounds like we're really close with our solution here.
Comment #25
agentrickardPerhaps a caching issue? Also, be sure that the variable is named correctly.
Comment #26
amariotti commentedI tried it on multiple computers/browsers and still get the same thing. Not sure what's going on here, but it's kind of frustrating.
Here's my domain_conf.inc file:
Comment #27
agentrickardIn between #9 and #12 you transposed the variable name incorrectly and we didn't catch it.
The proper name of the variable seems to be 'googleanalytics_account', so you need:
Comment #28
amariotti commentedExcellent! Thank you SOOOOO much! I'm going to go and blog about this for those who want to do this in the future.
Comment #29
agentrickardComment #31
amariotti commentedWith the most recent "6.x-2.0-rc6" this appears to still be working, but for some reason when you save the settings page it defaults back to displaying "UA-" in the Google Analytics Code field. Any ideas why this would be happening? As I said before, the feature still works but for some reason the settings page isn't displaying the saved code on each individual domain settings page.
Comment #32
awolfey commentedsubscribe
Comment #33
agentrickardThis has been cleaned up signifcantly in rc7.
lets open a new issue if this recurs.
Comment #34
amariotti commentedJust updated, and I'm still seeing the "UA-" show up as the default.
Comment #35
agentrickardlets open a new issue if this recurs.
With details.
Comment #36
newbie999 commentedHello nonsie. I tried the route you suggested - 1 google analytics account for my main domain and its subdomains. However, when I go to my google analytics reports and add advanced segments by 'domain' (specifically, by sub1.domain.com, sub2.domain.com), no data is reported. Would you be able to point me in a direction where I can get a clue as to why google analytics is not seeing any subdomain data? I use the domain access module and I have configured all domains to use the same google analytics account.
Thank you so much for any help you can provide.