I am supporting a Drupal v5 site serving two different domain names. We're using a single database and code base. Each domain name has it's own theme and multiple page.tpl.php variants.
Currently we are hard-coding the GA javascript code into all of the page.tpl.php files with the specific GA account number appropriate for the theme. Because of JS errors we are getting, I need to move the hard-coded JS script to the bottom of the page.tpl.php file in all of those files.
It appears that the GA module can not support multiple account numbers and GA itself wants a single domain name for each account number.
Any ideas on how I can utilize two account numbers in the GA module? Even if I have to resort to custom code?
Thanks.
| Comment | File | Size | Author |
|---|---|---|---|
| #9 | multipleaccounts-697168-9.patch | 1.1 KB | mnovikova |
Comments
Comment #1
hass commentedPut this into "below" field of custom java script.
Comment #2
dpearcemn commentedThank you for helping.
One question, when you say "below" field, are you referring to the "after" field?
Thanks.
Comment #3
hass commentedYes
Comment #5
nitrospectide commentedI have followed this, but the two GA accounts are reporting different results. Why?
Comment #6
nitrospectide commentedstatus change
Comment #7
hass commentedImpossible or bug at google. Ask google, please
Comment #8
newmediaist commentedI believe the referenced code may be out of date if you are using the Asynchronous GA tracking code - the correct method for tracking two profiles is here:
http://code.google.com/apis/analytics/docs/tracking/asyncUsageGuide.html...
Comment #9
mnovikova commentedHere is an implementation of tracking two Google Analytics accounts. One of them is statically set up in the module settings another number is dynamically invoked for each particular page.
Comment #10
hass commentedRTFM
Comment #11
martijn houtman commentedYou can make the variable translatable, and set a different tracking ID for each language.
Comment #12
gstout commentedthe latest
https://developers.google.com/analytics/devguides/collection/analyticsjs...
Working with multiple trackers
In some cases you might want to send data to multiple properties from a single page. This is useful for sites that have multiple owners overseeing sections of a site; each owner could view their own property.
To track data for two separate properties, you need to create two separate trackers, and at least one of them must be a named tracker. The following two commands create a default tracker and a tracker named "clientTracker":
ga('create', 'UA-XXXXX-Y', 'auto');
ga('create', 'UA-XXXXX-Z', 'auto', 'clientTracker');
So just add this in the after field with your second account UA id.
ga('create', 'UA-XXXXXX-1', 'auto', 'grsTracker');
ga('grsTracker.send', 'pageview');