Mobile app version of vmapp.org
Login or Join
Deb1703797

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

@Deb1703797

Posted in: #Drupal #GoogleAnalytics #Tracking

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

Code 1:
before

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


after

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


Code 2:
before

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


after

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


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

10.01% popularity Vote Up Vote Down


Login to follow query

More posts by @Deb1703797

1 Comments

Sorted by latest first Latest Oldest Best

 

@Kristi941

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]);
_gaq.push(["hello._trackPageview"]);


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.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme