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.

CommentFileSizeAuthor
#9 multipleaccounts-697168-9.patch1.1 KBmnovikova

Comments

hass’s picture

Status: Active » Fixed

Put this into "below" field of custom java script.

var secondTracker = _gat._getTracker("UA-XXXXXXX-2");
secondTracker._initData();
secondTracker._trackPageview();
dpearcemn’s picture

Thank you for helping.

One question, when you say "below" field, are you referring to the "after" field?

Thanks.

hass’s picture

Yes

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nitrospectide’s picture

I have followed this, but the two GA accounts are reporting different results. Why?

nitrospectide’s picture

Version: 5.x-1.9 » 6.x-2.2
Component: Documentation » Code
Status: Closed (fixed) » Active

status change

hass’s picture

Status: Active » Closed (fixed)

Impossible or bug at google. Ask google, please

newmediaist’s picture

I 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...

mnovikova’s picture

StatusFileSize
new1.1 KB

Here 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.

hass’s picture

RTFM

martijn houtman’s picture

Issue summary: View changes

You can make the variable translatable, and set a different tracking ID for each language.

gstout’s picture

the 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');