Does anyone know the different between these two sets of code for Drupal Google Analytics module? Which one is correct?

Code 1:


_gaq.push(["_setDomainName", "none"]);
_gaq.push(["_setAllowLinker", true]);


_gaq.push(["_setAccount", "UA-XXXXX-X-2"]);
_gaq.push(["_setDomainName", "none"]);
_gaq.push(["_setAllowLinker", true]);

Code 2:


_gaq.push(["_setDomainName", "none"]);
_gaq.push(["_setAllowLinker", true]);


_gaq.push(["b._setAccount", "UA-XXXXX-X-2"]);
_gaq.push(["b._setDomainName", "none"]);
_gaq.push(["b._setAllowLinker", true]);

I found these codes from here and from Google; the 2nd one is from Google with "b."

1 Answer 1


The b. bit is for if you have multiple trackers on the site. The "b" is just to identify it as different from any other tracker, but that could be any text at all. For example:

_gaq.push(["hello._setAccount", "UA-XXXXX-X-2"]);
_gaq.push(["hello._setDomainName", "none"]);
_gaq.push(["hello._setAllowLinker", true]);

would also work.

Both your code examples should work if you only have one account. The "b." one is recommended if you have more.

The first link you give doesn't use names like this for multiple trackers, I see. This will probably work because the javascript commands (setAccount, setDomainName etc) are called linearly. When "setAccount" is called a second time, any command that comes after will presumably be applied to this account, and not the first.

Giving each account a separate name allows you to run a command on them in any order, and prevents the potential for the two getting mixed up.

  • Does it mean I have to use "b." if my Drupal wanna run "UA-0000001-1" and "UA-0000002-1" but not "UA-0000001-1" and "UA-0000001-2"?
    – CocoSkin
    Jul 11, 2014 at 17:50
  • One more question. If I use the same 2nd ID(example "UA-0000002-1") on multiple sites, should I use _gaq.push(["a._setAccount", "UA-0000002-1"]);, _gaq.push(["b._setAccount", "UA-0000002-1"]);, _gaq.push(["c._setAccount", "UA-0000002-1"]);.....?
    – CocoSkin
    Jul 11, 2014 at 18:07
  • It shouldn't be about what Drupal wants to run, it should be about what data you want to collect. You only need to use a,b and c naming if you have multiple analytics accounts and they all need to collect data from the same page.
    – RichardB
    Jul 11, 2014 at 18:39
  • That helped me alot. Ty Richard B
    – CocoSkin
    Jul 11, 2014 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.