Advanced JavaScript Tweaks in the Google Analytics Module for Drupal 6.x

Posted Date: 
Fri, 06/26/2009

What we're covering today:
 + Add Custom Search Engine
 + Track domain and sub-domains
 + Convert referrals into direct traffic
 + Turn off browser tracking module
 + Turn off title detection
 + Track activity in multiple Google Analytics accounts

About Google Analytics Module:
The Google Analytics module for Drupal 6.x integrates Drupal's powerful site administration tools so you can harness the fullest potential of your Google Analytics account.  The module offers user-specific, role-specific, and page-specific tracking.  It can send role or profile information to Google Analytics so you can run user segmentation reports.  You can easily extend your Google Analytics with custom JavaScript code.  The possibilities are endless!

About Google Analytics:
Google Analytics is the next-generation web analytics tool that show you how people find your site, how people navigate through it, and how they become customers. Google Analytics is both easy to use and offers an enterprise-class reporting interface.  Google Analytics is also free!
 

Primary Screencast: 
Syndications

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

New code snippet

Thanks for this great tutorial. If I use the GA version 6.x-3.0 with the asynchronous tracking, is it enough to adjust the code as follows to track a page in two different accounts:


_gaq.push(['_setAccount', 'UA-xxxxxxxx-1']);
_gaq.push(['_trackPageview']);

If I add this in the after code snippet section, will that work? in the Google documentation they recommend to only use one push with multiple commands.


_gaq.push(
['_setAccount', 'UA-XXXXX-1'],
['_trackPageview'],
['b._setAccount', 'UA-XXXXX-2'],
['b._trackPageview']
);

Will there be a noticeable performance issue if I use the GA module option with two accounts and two separate push calls?

Thanks, Jens

Nice information shared

Nice information shared here.It proved to be Very helpful to me.
Thanks

Good info for JavaScript - Drupal

I totally agree- This information was very helpful to me too. I am a new webmaster and this was laid out in a very easy to understand way. Thanks Jimmy V Webmaster ABC Fundraising

Asynch?

Brian,

Great screencast...love it. Very helpful. However if I'm not mistaken those snippet examples would need to be modified to work with the Asynchronous version of the GA code, correct?

Also, wondering if you had any thoughts on this feature request I left on the GA module issue tracker page. http://drupal.org/node/954748 Is there a way to do this with the existing module/code that I'm missing?

Thanks again...great stuff!

Did Alexander Hass adequately

Did Alexander Hass adequately answer your question in the drupal.org issue?

He sure did...thanks!

He sure did...thanks!

multiple GA numbers, but only on selected pages.

Brian,

I can see how you could do GA numbers for an entire site, but what if you only want a second GA number for selected pages on a site? Is that possible?

Doug

Brilliant!

Brian --

Many thanks for the google_analytics Drupal module and the excellent screencasts describing how to use it. As an open source developer myself, I know exactly how much time and effort it takes to make high-quality software and then how much *more* time it takes to make a great screencast (or bunch of them) to enable people to your use software.

Just wanted to say "thanks! woo hoo!" from a random guy out on the internet. :-)

- Jeff Squyres

I can't take all the credit!

Jeff,
I really appreciate everything you said!  But, I need to clarify one thing: I didn't develop the google analytics module!  Like you, I thought it is a rocking awesome module and I wanted to give back to the Drupal community by developing some awesome screencasts to help others use it.  :-)
Peace,
Brian

Oops :-)

Ah! Good clarification. But the screencasts are darn awesome anyway. :-)

Thanks!

- Jeff Squyres

Custom JavaScript code and JavaScript Scope

Hi Brian,

Thanks for the video! I'm trying to configure ga to track a 3rd party shopping cart (see http://www.google.com/support/googleanalytics/bin/answer.py?hl=en&answer...). To do so, I've entered the snippets below into the Code snippet (before) section. And I've added the onclick="pageTracker._link(this.href); return false;" to the outbound link.

pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);

In you experience, is this set-up correctly? When implementing the snippets below and call to _link, is it true that the JavaScript Scope in /admin/settings/googleanalytics need to be set to "Header"?

Thanks in advance!
jwant

You rule, Brian!

Hi Brian,

again, I just want to thank you a lot your cool screencast on Google Analytcis modules.

I have learned a lot from them, and and laughed loudy a few times while watching them.

I'm aching to see the "Tracking Adsense" clicks.
Do you have an estimated release date for the pending videos?

You have a new fan!

I've been trying to get the

I've been trying to get the Adsense to work on my account, but I think the folks at Google linked my Adsense and Google Accounts wrong.  Not a bit of data is transferring to GA, and I've been troubleshooting it for MONTHS.  That part of my video series has been unfortunately delayed until I can get some help from Google.

I really enjoy your video and

I really enjoy your video and have learned a lot from it. Would you please tell me if it is possible to track visitors' IP addresses in Google Analytics report? Thank you very much.

great question!

That was one of my first questions when I first got on board with Google Analytics.  The short answer is: no.  However, there is a but.  BUT, you can view the owner of that IP address as reported by ARIN.  Check out this tab:
Visitors > Network Properties > Network Location
Also, if you want to include or exclude an IP address or a range of addresses, Google is kind enough to let you do that:
http://analytics.blogspot.com/2009/06/back-to-basics-filtering-out-your-...
Peace,
Brian

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

Subscribe to Drupal Screencasts (RSS)