Archive for June, 2008

Enabling cross domain tracking with unsupported navigation – Part 3

Saturday, June 21st, 2008 by Adrian Vender
Google Buzz

This is a 3 part series on cross domain tracking with Google Analytics in non-standard situations:

  1. Part 1
  2. Part 2
  3. Part 3

In this final of our three part series, we’re going to look at adding the Google Analytics query string parameters used to accomplish cross domain tracking to other variables we may be passing.

If we want to append additional query string variables to the end of our destination URL string we might try something along the lines of the following:

<code>
function redirectFunction()
{
window.location.replace(GoogleAnalyticsCookieAppend('http://www.xxx.yyy/
RedirectTarget.html?mookie=pookie'));
}
</code>

If we do this, it’s possible that we might also notice that our cookie passing solution no longer works.

Uh-oh.

If you find yourself in this situation, it might be because of this:

<code>
http://www.xxx.yyy/RedirectTarget.html?mookie=pookie#__utma=
1.283748562613819500.1212185562.1212185562.1212189988.2&__utmb=
-&__utmc=1&__utmx=-&__utmz=1.1212185562.1.1.utmcsr=
(direct)|utmccn=(direct)|utmcmd=(none)&__utmv=-&__utmk=100666753
</code>

The Google query string parameters were appended at the end of our query string, but with a “#” separator. Not exactly what we were expecting.

A cheap, quick and dirty fix is obvious: replace the “#” with a “&” and be on our way. But keep in mind that a simple replacement may create a problem with existing query string variables if being built dynamically, since we must have a “?” to start the query string parameters and must separate them with a “&” in a URL.

One solution is to extract the existing query string variables first, then call the GA function, then deal with the #/?/& issue,  and then append the old variables at the end.  We update our function to take care of this below:

<code>
function GoogleAnalyticsCookieAppend(uri)
{
//grab existing query string variables
var queryStringIndex = uri.indexOf('?');
var queryString =(queryStringIndex == -1) ? "" : uri.slice(queryStringIndex+1);
var myURI = (queryStringIndex == -1) ? uri : uri.slice(0, queryStringIndex-1);
//Use the Google Analytics function to get GA variables
var c = pageTracker._getLinkerUrl(myURI, window);
//Explicitly check in case GA is using #
c = c.replace("#", "?");
alert(c);
//reappend querystring variables
c += "&"+ queryString;
return c;
}
</code>

And that’s it for this mini-series on exploring the ins and outs of Google Analytics with non-standard tracking across top level domains.  Happy Google Analytics-ing!

Go to Part 1 or Part 2




    Adrian Vender
    Adrian is a technical lead and search engine optimization expert at WebShare. You can find out more about Adrian here.

    See more posts by Adrian Vender

    Enabling cross domain tracking with unsupported navigation – Part 2

    Thursday, June 19th, 2008 by Adrian Vender
    Google Buzz

    This is a 3 part series on cross domain tracking with Google Analytics in non-standard situations:

    1. Part 1
    2. Part 2
    3. Part 3

    When faced with a non-hyperlink and non-form submission crossing of domains, our first thought might be to write a method that simply takes the GA query string variables (generated by our standard solutions) and appends them to the end of our destination URL.

    But, Google Analytics is doing a bit more than this in its dedicated functions.  Specifically, it uses a hash function as a checksum in order to make sure that the cookies being passed are from the desired source (this ensures that you cannot maliciously affect someone else’s data using GA cookies). This checksum is calculated on the server side and stored in the _utmk variable.  Having to write your own server side hashing by reverse engineering the algorithm GA uses to do this checksum isn’t our ideal situation.

    So what to do?

    The first thing we have to do is undersant how the _link() and _linkByPost() functions are working. Looking specifically at some of the ga.js codebase, we see:

    <code>
    a._link=function(b,e)
    {
    if(i.I&&b){
    a._initData();
    a.a[p].href=a._getLinkerUrl(b,e)}
    };
    a._linkByPost=function(b,e){
    if(i.I&&b&&b.action){
    a._initData();
    b.action=a._getLinkerUrl(b.action,e)
    }
    };
    </code>

    One thing we immediately notice is that both functions require a URI to be passed in, and yet take two parameters, the second being “e”…and both then take this and pass it and the target (b for hyperlinks and b.action for forms) along to a _getLinkerUrl() function. Let’s take a closer look:

    <code>
    a._getLinkerUrl=function(b,e)
    {
    var j=f(b,"#"),t=b,v=a.qc();
    if(v)if(e&&1>=j[w])t+="#"+v;
    else if(!e||1>=j[w])if(1>=j[w])t+=(r(b,"?")?"&":"?")+v;
    else t=j[0]+(r(b,"?")?"&":"?")+v+"#"+j[1];
    return t
    }
    </code>

    Again, we see the “e”, and in order to figure out what’s happening, it’s important to understand some of the features and quirks of Javascript, like:

    • Constructors can return values
    • No block scope
    • Reserved words can be overriden
    • Every function returns a value

    As objects are essentially associative arrays, they are dynamically capable of adding properties and methods. The key to understanding “e” is found in the following declaration:

    <code>
    var _gat=new Object(
    {
    c:"length",
    lb:"4.2",
    m:"cookie",
    b:undefined,
    cb:function(d,a){this.zb=d;this.Nb=a},
    r:"__utma=",
    W:"__utmb=",
    ma:"__utmc=",
    Ta:"__utmk=",
    na:"__utmv=",
    oa:"__utmx=",
    Sa:"GASO=",
    X:"__utmz=",
    lc:"http://www.google-analytics.com/__utm.gif",
    mc:"https://ssl.google-analytics.com/__utm.gif",
    Wa:"utmcid=",
    Ya:"utmcsr=",
    $a:"utmgclid=",
    Ua:"utmccn=",
    Xa:"utmcmd=",
    Za:"utmctr=",
    Va:"utmcct=",
    Hb:false,
    _gasoDomain:undefined,
    _gasoCPath:undefined,
    e:window,
    a:document,
    k:navigator,
    t:function(d){
    var a=1,c=0,g,o;
    if(!_gat.q(d))
    {
    a=0;
    for(g=d[_gat.c]-1;g>=0;g--)
    {
    o=d.charCodeAt(g);
    a=(a<<6&268435455)+o+(o<<14);
    c=a&266338304;
    a=c!=0?a^c>>21:a
    }
    }
    return a},
    </code>

    So “e” is actually just the window itself.  Now that we know that by passing in the url and the window object to _getLinkerUrl(), we are able to handle both hyperlinks and forms, we can see if it will work for our DIV container example. Let’s give it a try…

    <code>
    function GoogleAnalyticsCookieAppend(uri)
    {
    var c = pageTracker._getLinkerUrl(uri, window);
    return c;
    }
    </code>

    We can test this and see that our cookies are indeed being passed.  Now, what if we want to pass info with other query string variables?

    Continue to Part 3




    Adrian Vender
    Adrian is a technical lead and search engine optimization expert at WebShare. You can find out more about Adrian here.

    See more posts by Adrian Vender

    Enabling cross domain tracking with unsupported navigation – Part 1

    Wednesday, June 18th, 2008 by Adrian Vender
    Google Buzz

    This is a 3 part series on cross domain tracking with Google Analytics in non-standard situations:

    1. Part 1
    2. Part 2
    3. Part 3

    In figuring out how to use Google Analytics on a site that spans multiple top level domains, (i.e. transfer cookies across multiple domains) there are many good resources out there (books, blogs, helpfiles and more). Given the amount of work done on this topic and the frequency with which it occurs on websites, you might not think this would be a difficult problem, and in most common cases, it isn’t.

    But while there are well documented and standard methods that specifically deal with hyperlinks and HTML forms, you may find yourself in some unfamiliar territory if your site uses other types of navigation methods (scripted redirects, server side, etc…).

    Take, for example, the simple snippet below:

    <code>
    <a href="" onclick="redirectFunction()">Link across top level domains</a>
    function redirectFunction()
    {
    window.location.replace('http://www.xxx.yyy/RedirectTarget.html');
    }
    </code>

    To address this one, you might write a wrapper function that encapsulates the redirect and inserts a call to the pageTracker._link(<urlToRedirectTo>) function, so we’d do something like the following:

    <code>
    function redirectFunction()
    {
    window.location.replace(GoogleAnalyticsCookieAppend('http://www.xxx.yyy/
    RedirectTarget.html'));
    }
    function GoogleAnalyticsCookieAppend(uri)
    {
    pageTracker._link(uri);
    return uri;
    }
    </code>

    Note: You’ll want to make sure to include the “return false” at the end of your call here.

    This will work for cases where we have a hyperlink (anchor tag) doing this direct javascript call, as follows:

    <code>
    <a href="" onclick="GoogleAnalyticsCookieAppend('http://www.xxx.yyy/
    RedirectTarget.html');return false;"> This one tries indirectly  </a>
    </code>

    But what about something that’s not a hyperlink, like a div container?

    <code>
    <div id="mydiv" onclick="redirectFunction();return false;">
    Content for this container
    </div>
    </code>

    This is neither a hyperlink nor a form, and our attempts at solving this problem with pageTracker._link() and pageTracker._linkByPost() just don’t seem to work…

    Continue to Part 2




    Adrian Vender
    Adrian is a technical lead and search engine optimization expert at WebShare. You can find out more about Adrian here.

    See more posts by Adrian Vender

    Video Search – New sites like Truveo offer up great search marketing opportunities

    Wednesday, June 11th, 2008 by Dave Reichenbacher
    Google Buzz

    In these days of viral videos, there is some pretty entertaining content out there. There are millions of videos on YouTube alone, and there are plenty of other sites out there like Break.com and Newgrounds with millions of videos all their own. Even non-traditionally video oriented sites like CNN.com and Disney are posting videos for user entertainment. With so much content spanning so many sites, it is easy to spend hours searching for “that one video I saw on that one site”…enter Truveo into this new landscape of video search.

    Truveo is a video search engine that indexes many popular websites for videos. It offers users a one-stop shop for search and viewing of their favorite virals. Since it pulls content from partner sites, it offers unique opportunities for search engine marketing, giving aspiring marketers another avenue to have their content reached. An effective marketing strategy can open a completely new world of millions of possible leads.

    Although they were at first regarded as a way of reaching primarily younger audiences, viral videos are quickly becoming a medium for populations for many different demographics and backgrounds to come together over their mutual interests. Many companies have already leveraged these mediums effectively to create positive public buzz, and one example is Dos Equi’s Most Interesting Man in the world, which has created buzz all over the blogosphere (like this, this, and this).

    Truveo’s true potential lies in its international audience, which grows daily and has reported to constitute over 70% of their traffic. Many of their most popular videos are from young emerging markets like India and China, which creates an excellent opportunity for marketers to gain a visible presence in commercially exciting areas of growth. Marketers looking to go international may be able to leverage it as a viable option for creating buzz in different markets, and it is definitely worthy of a follow-up.




    Dave Reichenbacher
    DR directs program management and operations at WebShare. He also is one of our Seminars for Success instructors and has an affinity toward local search marketing. You can find out more about Dave here.

    See more posts by Dave Reichenbacher

    Robots and your Website – Google’s robots.txt File Generator

    Friday, June 6th, 2008 by Corey Koberg
    Google Buzz

    We’ve all seen the movies where the robots are coming for us, including classics such as The Terminator and The Matrix. What people may not know is that they already came for us – and got all of our information… In fact, the most widely used website in the world is built upon one of these robots: The GoogleBot.

    Indeed, not all robots are here to subjugate humanity and turn us into subservient slaves. They are actually quite helpful, indexing web sites on popular search engines so that visitors may come and indulge in the pages of our websites. Without these robots, most of the information revolution we’ve seen in the past 20 years would not have been possible.

    But what if you have some information on your website you’d rather not have the whole world take a look at? Perhaps a baby picture from when you were small that you only share with family friends, internal pages that you may want to keep out of the search results page from a business perspective.  There are many valid reasons for “banning” the bots from certain pages, and there are some good ways to do this.

    One answer is a robots.txt file. Essentially this is a text file (which can be written in any text editor) that issues commands to robots to visit only the portions of a website that you allow. The basic syntax is fairly simple, and a good overview is available here. We want to be very careful when employing these files, however, and make absolutely sure that we know what effects our actions will have.  For this reasons, many webmasters are uncomfortable with editing this themselves, as one small mistake could render your site entirely invisible (or entirely visible) to any robot.

    Luckily, Google now offers a tool that will automatically generate a robots.txt file for you, saving some time and perhaps avoiding an unintentional disaster.

    Robots.txt generator from Google Webmaster Tools

    Using this tool can help you control the pages of your website, and we can make sure our robots keep coming back on our terms, without terminating us.




    Corey Koberg
    Corey is a co-founder and principal consultant at WebShare...you can find out more about Corey here.

    See more posts by Corey Koberg

    Freeing Your Site’s Information: Google WebMaster Tools

    Monday, June 2nd, 2008 by Corey Koberg
    Google Buzz

    The internet is the largest and most varied medium of information in all of human history, housing literally billions of web pages ranging in topics from the mundane to the esoteric. Many companies struggle with determining how to make their websites visible and heavily trafficked on the Internet, and Google is helping out website owners, search marketing managers and webmasters with tools that include Content Analysis, Sitemaps, and more.

    Google Webmaster Tools - understanding your website with WebShare

    These tools are incredibly useful vehicles to develop and manage sites that a search engine can navigate and use, which any Search Engine Marketer will tell you is fundamentally important for the success and visibility of a site on the web. One aspect of this topic includes the importance of page elements and how to effectively leverage rich content like flash, AJAX, video, and more.

    One thing to remember is the importance of using textual alternatives for content that is primarily audio/visual for the benefit of searching technologies. While humans have the ability to comprehend the “message” behind this rich content, search engines cannot.  While we as humans can look at a picture of a car and understand and interpret what we’re looking at conceptually and even specifically, a search engine spider is left with nothing more than an array of pixels.  One way to “tell” a search engine what’s behind this content is to use alt attributes for images and noscript/alternative content for browsers without JavaScript/Flash.

    This has twofold importance. For one, this makes a site much more accessible to the visually impaired (who may use programs such as JAWS, a text/speech tool for visualization), and second, it helps search engine spiders index a site. Failure to use such options effectively leaves large portions of the internet essentially blind to your content, resulting in fewer page visits and less overall user engagement.  In order to be more than just another fish in the sea, webmasters should leverage these tools and techniques to free their information, bringing it into the light for all to see.

    If you’re not using Google’s Webmaster Central, get an account today and get instant visibility into the pages of your site.




    Corey Koberg
    Corey is a co-founder and principal consultant at WebShare...you can find out more about Corey here.

    See more posts by Corey Koberg