Advanced Google Analytics JavaScript Snippets

Last modified: August 21, 2009 - 20:34

Google Analytics module provides an advanced textarea on the settings page for including additional JavaScript to every page.

The official documentation about Google Analytics Tracking Code should be read first to understand how Google tracking works in general. On the Google Analytics Tracking API page you will find all available methods that can be used in this textarea. Additional you'll find JavaScript snippets dotted around in the Google Analytics Help Center.

Don't forget to prefix all used methods with pageTracker. as also shown below.

Add your Google Analytics advanced JavaScript snippets as comments to this page.

Tracking across multiple subdomains

budda - April 19, 2008 - 23:52

GA allows for tracking across multiple subdomains using a single line of script.

pageTracker._setDomainName("example.com");

See Further information for details.

no, it's

maku520 - November 10, 2008 - 19:35

no, it's this:

pageTracker._setDomainName(".example.com");

you missed the first period before the domain name.

Identify additional search engines in the Referral reports

hass - May 2, 2008 - 10:36

By default, Google Analytics tracks referrals from a growing list of search engines. You can also configure Analytics to identify referrals from additional search engines by adding the following line to your tracking code:

pageTracker._addOrganic("name_of_searchengine","q_var");

See here for more information.

Google Analytics without Javascript

poorni - January 14, 2009 - 19:38

Hi... I was just wondering if anybody knows anything about posting data on google analytics without using javascript? Any advice would be really appreciated... Thanks.

Google Analytics without

bennos - February 24, 2009 - 15:42

Google Analytics without Javascript? no.
You must provide date over an request and this can only be done by javascript on a page impression

It's me, BENNOS.

Google Script

hebhansen - March 12, 2009 - 12:16

Google proposes this script:

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-yourcodexxxx");
pageTracker._trackPageview();
} catch(err) {}</script>

What goes before and what goes after and how should it look in drupal? Without script tags?

all the best
HB

Use the Google Analytics

hass - March 13, 2009 - 16:55

You need to read http://code.google.com/intl/de-DE/apis/analytics/docs/gaJSApi.html what need to come "before" pageTracker._trackPageview(), but it is nearly everything... except E-commerce stuff and multi account tracking.

How to get 2 scripts of analytics?

moskit - November 24, 2009 - 20:40

I want track 2 separate codes. How can I do this?

 
 

Drupal is a registered trademark of Dries Buytaert.