Solved

google analytics with hash marks (jquery tabs)

Posted on 2011-09-26
1
753 Views
Last Modified: 2012-05-12
I use jquery tabs on my homepage.  when you arrive at the homepage, it's like:

http://www.home.com

then if you click about us, it's like:

http:www.home.com/#about

jquery uses hash marks to keep track of the tabs. I would like to use google analytics to record data on which tabs are getting clicked and/or linked to.

I've found some sort-of-answers on stackOverflow, but to be honest, they just aren't dumbed down enough for me. It seems like I need to use a simple string replace to send GA a / instead of a # and then the tab can be tracked. But I don't know if that works for links or just tab-changes. Also, I don't know how to integrate it into the code at the bottom of the page. And I definitely don't understand how to add the connections to the Google Analytics page: are they separate profiles or accounts? do i add them using slashes or hashes.

Thank you for any help you can offer! I know there are a lot of questions here!
0
Comment
Question by:hibbsusan
1 Comment
 
LVL 6

Accepted Solution

by:
mattjp88 earned 500 total points
ID: 36715728
so GA tracks pageviews, and since using the hash isn't reloading the page, GA isn't tracking it.  Check out http://www.google.com/support/analytics/bin/answer.py?answer=55485 .  Basically you'll want to call this when you change tabs, changing /about to the correct name

 _gaq.push(['_trackPageview', "/about"]); 

Open in new window


GA doesn't track the hash value, so you'll need to make up fake "pages" for GA so it thinks those are real pages.  For example, example.com/#about is the same as example.com/ in the eyes of GA, so you'll need to tell google that the page is actually example.com/about (notice the slash instead of hash).

As for how you'll call that GA function, you'll need to read up on whatever jquery plugin you're using for a callback when a tab is clicked.

-Matt
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now