New Referrals (links) As Google Analytics’ Goals

August 24th, 2010

I’ve been experimenting with setting up a goal in Google Analytics that tracks new referrals, ie, links.  This way if I have a blog post or seo tool that becomes popular I can track how popular it actually was in terms of new links pointing to it.   Consider this scenario: You create a great piece of link bait on your website.  Next you need to promote it.  Part of your off page strategy involves ppc ads on Google in order to gain visibility and in turn generate links.  With the ability to track new links as goals, you can then import that goal into Google Adwords and track it as a conversion.  In order to accomplish this you need to use the Google Analytics Data Export API to check if the referring url is already in Google Analytics as well as jQuery.  Enough said, here is how I do it:

1) Create a file called trackReferrer.php to do the work with Google Analytics Export API. I prefer using the GAPI class. What we need to do is query GA for a referring url. If it exists, it is not a new link. I really only care about new domains that link, not new pages on sites already linking, so im just querying the host, not the path.

< ?php
//load the GAPI class
include("/path/to/gapi.class.php");
define('ga_email','xxxxxxx@gmail.com');
define('ga_password','xxxxxx');
define('ga_profile_id','xxxxxx');

$ga = new gapi(ga_email,ga_password);

//we are going to pass the referrer via a get parameter
$url = filter_input(INPUT_POST,
                      'url',
                      FILTER_SANITIZE_STRING);

$url = parse_url($url);
//GA filters our www subdomains, so we must do the same
if(@substr($url['host'],0,4)=='www.') {
  $host =  str_replace('www.','',$url['host']);
} else {
  $host =@ $url['host'];
}

$sort=null;
$filter="source=~'^$host' && medium==referral'";

//this date should be one day before you installed GA
$start_date = '2006-01-01';
$end_date = date('Y-m-d',strtotime("+1 day"));
$start_index=1;
$max_results=100000;

$ga->requestReportData(ga_profile_id,
                      array('source','referralPath'),
                      array('visits'),
                      $sort,
                      $filter,
                      $start_date,
                      $end_date,
                      $start_index,
                      $max_results);

//if greater than 0, its not new
if (count($ga->getResults())==0)
{
  echo 1;
} else {
  //new domain linking
  echo 0;
}

2) The next step is to add a bit of code to the footer of each page of your site that passes the HTTP_REFERER to the new page we just created. I use jQuery to post the referrer after the page is loaded because the GA Export API can take some time to load, so i don’t want to slow down my site for the user.


< script type="text/javascript" >
$(document).ready(function(){   $.ajax({
          url: 'trackReferrer.php',
          dataType: "HTML",
          type: 'POST',
          data: {'url': '< ?php echo $_SERVER['HTTP_REFERER']; ? >'},
          success: function(msg) {
            if(msg==1) {
               pageTracker._trackPageview('/virtual/new_link')
            }
         }
   })
 });
 < /script >

3) The last step is to setup a regular expression goal in Google Analytics with the url path being /virtual/new_link(.*), then import that goal to adwords if you are doing it for that sake.

RascalNet

July 8th, 2010

I finished my pet sitting several years ago and decided to get into web development and SEO. One of my main goals of the switch was an idea I had for pet sitting software.  Just wanted to say im finally on course to making it a reality.

Onsite Google Analytics Plugin

July 5th, 2010

Over the past week I’ve been developing my first WordPress Plugin, Onsite Google Analytics.  The plugin is built for non-technical users who don’t have a good understanding of Google Analytics and are not used to viewing their data from the Google Analytics interface.  The ideas is to pull some valuable metrics right onto their site so that they can better understand their website visitors.  I’ve created a permanent page with a full overview and q/a.

The Link Counseling Center

June 19th, 2010

My latest addition to the flickr group, The Web in Real Life:

The New Billboard

June 11th, 2010

Because I work at such an awesome online marketing agency, I was recently exposed to a great film on advertising, Art & Copy.  The film really opened my eyes to advertising. More importantly I found a strong comparison between advertising and SEO.

Follow me on an analogy for a moment. If every business could put up a billboard for less than $20 per month, and the business owner had the ability to direct what goes on that billboard and a lot of the time could create the content and put it up themeselves, what would those billboards look like?

The fact of the matter is, with such a low barrier to entry you will have businesses putting up billboards that look like Microsoft Word documents, full of business speak, overcrowded, and all about themeselves.  I know this because I see it everyday in poorly thought out websites put up by people who do not understand advertising.

What would it take to get that billboard to stand out from every other billboard on the street?   What about to get people talking about that billboard?  Some companies will get it and put cows on them with just a few words, but most will not.  Sadly, this is the state of the Internet.  Your website is a billboard and a strong SEO campaign means getting people to turn their head and think about your message. It’s Advertising.

The fact of the matter is this is the future of SEO.  Provide a great billboard by making your website easy to understand, fun, exciting and useful.  That’s my challenge as an SEO, useful.  If you can make a website useful with valuable content, tools, web apps, engagement, games, etc, and build that on top of a solid technical on-page SEO strategy, you will be extremely successful at SEO.

My advice is to do it now because the a lot of the medium to big size companies that have the budgets to create awesome website content, tools and the rest of the good stuff, are not aware of this secret and once they find out, you will not be able to compete.

Photo courtesy of Daveness_98

The Web in Real Life

June 5th, 2010

Quick post on my recent Flickr group, The Web in Real Life.  I spend way to much  time on the web and sometimes It seems that its starting to invade my web life.  Here is a link to the group as well as a few photos.

Oracle Database:

Altavista:

Unique Domain:

The Content License

May 6th, 2010

Licensing your content is a great way to gain links. The problem is that most business are not willing to change their business strategy for the sake of their website. Many businesses still see their website as just “a page” on the internet and are missing the most powerful marketing opportunity available. Many businesses already license their products or services in one way or another, so its not a big stretch to include in the details a link back to your web site.

Here are a few ways for different types of websites / business to license their content:

  • Real estate companies: They take great photo’s of some houses to sell the house, but why stop there.  Once the house sells, or even before it sells, add the photo’s to Flickr and use a Creative Commons license. This is really easy to do, requires no legal team, and will gain you some great links if your a good photographer.
  • API / Web Services:  SEOMoz provides a great API to get metrics on websites such as Page Authority, Domain Trust, and other really useful information.  As a condition of using their free API, they specify that you link to their website. Although creating an API may seem like a large upfront task, if you invest in the money and create something of value, it will really pay off in the long run. Companies spend tens of thousands of dollars a month on ppc generating no long term ROI, why not spend some of that money on an API and create some strong organic results that will last a long time.
  • Licensing content is another way to get links.  Create graphs, images, or even industry reports for complimentary products and services.  The key here is to invest in great work.  For graphs and images, have a real artist create them.  For industry reports, have an expert write it.

Licensing content can take time and money on your part, but its important to understand that strong natural search rankings are anything but free. On the bright side, its certainly less expensive than buying the keywords in ppc over a long period of time.

Form Optimization with Google Analytics

April 17th, 2010

This is a follow up post on a Google Analytics blog post by Tomasz Lewandowski from Bluerank.   It is about measuring the success of an online form with Google Analytics.  If you have not read that post, stop now and do so, as the rest of this post will not make any sense.

When someone goes to the contact page of this site and does not fill out all the fields properly, I know now thanks to the insight from Bluerank.  By measuring your form error rate (FER) you are able to gauge what form fields your users are having trouble with and provide some helpful information around that field. The end goal is to provide a better user experience and decrease your form abandonment rate.

Anyways, I do a lot of form validation with the jQuery Validation Plugin, so I figured I would share how to incorporate this tracking into that plugin. How exactly to use that plugin is beyond the scope of this post, but there is lots of documentation on jQuery with examples to help you learn.  In order to use the plugin to measure your FER you need to add an invalidHandler function to the validate method.

$(document).ready(function() {
  $("#leadForm").validate({
    invalidHandler: function(e, validator) {
      var errors = '';//set errors to empty
      validator.currentElements.each(function(){
        if (validator.element($(this)))
        {
          errors+=0 //add 0 for passing
        } else {
          errors+=1 //add 1 for fail
        }
      }); //end validatorCurrentElements
      //the google analytics call to track pageview
      pageTracker._trackPageview('/virtual/forms/'+errors);
    } //end invalidHandler
  });//end validate function
});//end document ready

As you can see from the code, I used /virtual/forms/ as the root path to the virtual pageview.  In Google Analytics, an incorrect form submission will look like a pageview of  /virtual/forms/0100 for a form with four required fields and the second field failing validation (a 1 is a failure, 0 is a pass).  I use /virtual/forms/0000 to denote a form submission success because I only validate four fields for this specific form. This is not shown in the above code, but you should call it on your forms thank you page like so:

$(document).ready(function() {
   pageTracker._trackPageview('/virtual/forms/0000');
});

One of my many super powers is confusing people, so feel free to post questions :)

The List

April 15th, 2010

Creating insightful lists as a resource for your visitors can be an extremely powerful tool to acquire links.  The trick is to spend some time gathering the best information you can find and come up with a long list of resources.   Your list could be resources (bookmarks) of other websites or your own content as well. Smashing Magazine, a web design and development website is famous for its long creative lists such as this one.  I’d suggest compiling your list over a long period of time, finding the the best resources and a wide variety of them.  If you are able to come up with something valuable, people with share your website and you will be rewarded with lots of links. Here are a few other examples of lists created by industry experts:

The Discount

April 12th, 2010

The discount is an extremely successful link building technique for ecommerce related sites. The trick is to offer discounts to websites/businesses with a coupon code. 1800-Flowers has used this technique to obtain many high quality edu website links (links from .edu domains are stronger than regular domains in the eyes of Google) from a variety of schools student discount program.  Schools, government organizations and industry associations are happy to give away links to your website if your able to speak directly to them with a link offering their visitors discounts.  Create a coupon code tailored to each link target and you will find a greater success rate of your link building campaign.  Here are a few link queries to get you on your way:

Experiment with different versions of the above queries and you will find a lot of high value link opportunities.

Image courtesy of TW Collins