Foliotek Developer Blog

In Depth Google Analytics Tracking

Google Analytics is a wonderful tool to help understand how your website’s visitors behave. ?It’s pretty trivial to get some relevant information about what pages your visitors look at and how they get there – all you need to do is set up an account and add a script tag.

There are a bunch of more advanced ways to set up your Analytics account in order to also find out WHY visitors are doing what they are doing – and to get ideas about what you might be able to do to improve things.


Analytics goals are a way to identify key behavior you want your visitors to perform. ?Goals are often used to?identify?things like: visits to key pages, generation of leads, or new sales. ?You can even set a real/estimated dollar value for each goal completion – and Google will total those values in various breakdowns to help you decide how successful different site initiatives (adwords campaigns, etc.) are.


In today’s Web 2.0 world, many visitor actions are important that do not register a new page view. ?Examples include: click on a link that goes to an external site, play/stop/finish a promo video, submission of an Ajax-enabled form.

Example code (external link tracking):

[sourcecode language='html']

[ExternalLink’, ‘Click’, ‘Facebook’ ]);”>Facebook]()


Custom Values

Sometimes there is information that you’d like to track that doesn’t fit into standard categories. ?Google offers 5 variables for your use. ?Each can be filled with one value that can either be stored per page, session, or visitor. ?Note that Google will only store the most recent submission to each value if you submit more than one to the same slot per page/session/visitor. ?I used this capability to track breadcrumb lists of pages visited and videos played in a session (stored in a local cookie and submitted to google with each update). ?This info was valuable in my custom Analytics dashboards – I wanted to see how a certain page visit/video play (any time in the session, or last video watched, etc.) affected a goal conversion rate. ?I would have done this by filtering on completion of a second goal, but unfortunately that isn’t possible currently.

Example code (tracking page visit cookie list):

[sourcecode language='javascript']

if (pageid >= 0) {

$.cookie(‘PageIDs’, ($.cookie(“PageIDs”)||”") + pageid + “;”, { expires: 30, path: ‘/’ });


4, ? ? ? ? ? ? ? ? ? // ?slot

"PageIDs", ? ? // key

$.cookie("PageIDs"), ? ? ? ? ? ? ? // value

2 ? ? ? ? ? ? ? ? ? ?// scope(2=session)

]);? ? ? ? }


Custom Dashboards

Sometimes, the standard report pages Google offers aren’t enough. ?Thankfully, with the new version of Analytics – not only can you create a single page filled with custom graphs and stats – you can create multiple stat pages for different purposes. ?By filtering/displaying graphs based on goals, events, custom values, and other factors – you should be able to find out just about anything you want to know about the performance of your site. ?Saving it as a dashboard allows you to set it up once and easily review performance over time.