Capture Mobile Device Screen Orientation In SiteCatalyst

Recently I was speaking to someone who was in the process of creating an tablet experience for their visitors. At one point they asked the question “of my iPad visitors, how do I find out in what format do they view my site the most in, landscape or portrait?”. I started going through all of the reports in SiteCatalyst and tried to find the answer, but that information just was not available. So I decided to whip a little bit of code that would figure this out for us. I call this the screenOrientation plug-in.

Basically what this will do is it will check to see in what position the mobile visitor is viewing the site in, whether they are viewing the site in a portrait or a landscape view when the page loads, and capture that value into a SiteCatalyst variable.

To implement this plug-in you first need to take this code, and add it to your s_code file near the rest of your plug-ins.

function screenOrientation(){switch(window.orientation){case 0:case 180:return("Portrait");break;case 90:case -90:return("Landscape");}window.scroll(0,0)}

Next in the do_plugins section of the s_code file, add the call to the plug-in to what ever SiteCatalyst variable you want this data captured in. In the example here you can see I am capturing it in s.prop1

s.prop1=screenOrientation();

Thats all it takes. Once the code is implemented, if the device does not have an orientation value the variable will not capture anything, but if the visitor is on a mobile device with an orientation value, the value of Landscape or Portrait will be captured on each page load. You will end up with a report that looks something like this:

Mobile Screen Orientation Report

To make it easier to access the report I also moved it into the Mobile report menu by using the customize menus option in the admin console of SiteCatalyst.

SiteCatalyst Mobile Reports

enjoy!

Custom Link Tracking in Omniture using jQuery

One of the most common things I get asked to track are specific links on the website. Typically to do that I would use a custom link tracking function. This typically involves adding a large chunk of JavaScript code to each link, or adding a function to your s_code file and then calling that function using an onClick function added directly to the link. That methodology works fine, and I’ve been doing it forever. But that means working with IT to add more code to your pages, something I want to try to avoid as much as possible. So how can we make the implementation of our link tracking quicker and use less code? If you haven’t figured it out by now, we’re going to use some jQuery.

For more information how to do this, please read the full article Custom Link Tracking in Omniture using jQuery.

For more information on website optimization solutions, please visit Keystone Solutions.

Processing Rules in SiteCatalyst 15



Here is a quick look at what can be done with and how to set up processing rules in SiteCatalyst 15.

Enjoy.

Video Introduction To SiteCatalyst Target Reports



The SiteCatalyst Target report is one of my favorite reports that I don’t see used enough. THis video gives you a brief introduction to the report, and walks you through setting one up, and how to view the results.

Enjoy.

How To Stop Google Preview From Being Counted In SiteCatalyst

Google Instant Preview, designed to show you a visual preview of your search results, rolled out in early November 2010. You now have the ability to click a small magnifying glass icon next to each search result to get a snapshot of what the page looks like.
Google Instant Preview

Seems like a pretty helpful feature, but how do they do it? Well it would appear that Google has a new spider that crawls the web and takes snapshots of each page in its results. In order for them to get an accurate look at what the page looks like, this new bot needs to able to execute JavaScript. Here is the problem. Since it is executing JavaScript that means it is also firing off the SiteCatalyst code and is being counted as another visitor and is registering page views.

How can you tell if this new Google Web Preview bot hit your site? If you are capturing User Agent you can see it show up in that report:
User Agent Report

NOTE: If you are not capturing user agent and would like to, a super simple way would be to use the SiteCatalyst Dynamic Variable functionality and include s.eVarX=”D=User-Agent”; in your s_code.js file. Just insert the number of the eVar you would like to use (a s.prop would work too) and you are all set.

Another way to see if you are being affected with spider traffic in your report suite from the Google Preview Bot would be to check out a Browser report (Visitor Profile > Technology > Browsers) and filter it to only show visitors using Safari 3.1 and then trend it.
Browser Report
We can see that this report suite has recorded about an additional 15,000 visitors over the last week that is just attributed to Safari 3.1. Checking the User Agent we saw earlier, the Google Web Preview bot is registering itself as Safari 3.1.

Now that we can see that the Google Web Preview bot is having an effect on our traffic how do we get rid of it? We could block that bot in our robots.txt file, but I like having that additional functionality available for my visitors in the Google search results. I just don’t want it to execute my SiteCatalyst code. Well here is how to do it.

I call this my bot detection code (real catchy title, right?). I currently have it just set to look for the Google Web Preview bot, but it could easily be modified to exclude other bots that can execute JavaScript. Here is how you implement it. In your s_code file, at the top you will have a s_account variable that contains your report suite id. It will look something like this:

var s_account="dead"

To implement the bot detection code you will want to change that line to include the function call. It should look like this:

var s_account=botCheck("dead")

Pretty simple so far, right? We just added the function call and included our report suite id in it. Next we have a block of code that needs to be added to the plug-ins section of the s_code file:

function botCheck(b){var c=navigator.userAgent.toLowerCase(),a="";a+=c.indexOf("google web preview")!=-1?"":b;return a};

And that’s all there is to it. So how does it work you ask? What it does is it removes your report suite id if it is the Google Web Preview bot that is accessing the page. The SiteCatalyst code will still fire off, but it will not include the report suite id so it will be discarded by SiteCatalyst and it will not affect your metrics.

Want to see it in action? I thought you’d never ask! Check out the page http://webanalyticsland.com/test.php. On this page I have a basic SiteCatalyst implementation, one line of code that displays your user agent, and then I print the results of the SiteCatalyst debugger right to the screen. Opening this page in a standard Firefox browser we can see that the SiteCatalyst code has fired off properly, it has displayed the correct user agent and the report suite id is contained within the image request string.
Test 1
So far so good. Using the User Agent switcher plug-in for Firefox, we can switch out user agent to the one that we found in the SiteCatalyst report to mimic the Google Web Preview bot.
Test 2
We can now see that when we use that bot’s user agent string, the report suite id is missing from the image request call. Any action that happens now will not be recorded in my report suite, and when SiteCatalyst receives this request it will be discarded. I’ve had this running for a few days now and have not found any issues, but since this is a pretty new chunk of code be sure to test it out before using it on your production site.

Enjoy!

Pro Tip: Keep a Solution Design Document For Your SiteCatalyst Implementation

A Solution Design Document is a complete blueprint of your web analytics implementation. It outlines where every variable is set and why. It can really be a lifesaver. You should start keeping a solution design document as soon as you begin your implementation. Every time you add a prop, an evar, an event or any other variable, make sure you add it in there. Every time you make a change to your implementation, make note of it in there. It’s an easy place to go to see what variables are being used for what where they are being set and which ones are still available.

“But do I really need to keep track of everything to that level of detail, just checking the Admin console has been working well for us.” Well have you ever opened a report and find information there that shouldn’t be there?
Bad Report
How did that get in there? It’s being set somewhere in our implementation, but where? What page sets that variable? What function could set it? A quick check of our solution design document and we can see every place were that particular prop is set, well where they should be set. If one of your developers decided to get the implementation and set a variable in a non traditional way, it can be a real nightmare trying to figure out what was done. Without that you could waste a lot of time hunting through code searching for where a random variable is being set.

Here is an example spreadsheet that you can use as a basis to start your Solution Design Document:
Sample Solution Design Document

If you have a large team that all have their hands in your web analytics implementation, it may be beneficial to could place the solution design document in a location where the different members of your team can have access and add to it, like for example Google Docs or some other shared folder or public drive.

Enjoy!

Track HBX Style Links in SiteCatalyst

I hear from a lot of people migrating from HBX to SiteCatalyst who are looking for ways to make that process a little easier. One of the hurdles I see is trying to migrate all of their HBX link tracking that is already in place to a format that SiteCatalyst can easily understand. That is an easy one to tackle. It’s called the setupLinkTrack plug-in.

Other than tracking all of you current HBX coded links, any SiteCatalyst user can get some benefit from it. Here is another great use for this plug-in. Recently I was reading a great article from @adamgreco about learning to track website navigation. It is a really great article and if you have not had a chance to read it you should go check it out. In one part of the article Adam writes “you should have your developer write code that will pass the name of the link to a Traffic Variable (sProp) when a visitor clicks on each link in your navigation”. Well I’m the guy responsible for the tracking code for my website, so how can I track those links without adding a whole ton of JavaScript onclicks or some other server side hacks? This plug-in will easily handle that, without adding the extra server calls that come with the standard SiteCatalyst link tracking.

First take the plug-in code and add it to the plug-in section of your s_code.js file. Make sure you have the utility functions s.split and s.apl.

/*
 * Plugin: setupLinkTrack 2.0 - return links for HBX-based link
 *         tracking in SiteCatalyst (requires s.split and s.apl)
 */
s.setupLinkTrack=new Function("vl","c",""
+"var s=this;var l=s.d.links,cv,cva,vla,h,i,l,t,b,o,y,n,oc,d='';cv=s."
+"c_r(c);if(vl&&cv!=''){cva=s.split(cv,'^^');vla=s.split(vl,',');for("
+"x in vla)s._hbxm(vla[x])?s[vla[x]]=cva[x]:'';}s.c_w(c,'',0);if(!s.e"
+"o&&!s.lnk)return '';o=s.eo?s.eo:s.lnk;y=s.ot(o);n=s.oid(o);if(s.eo&"
+"&o==s.eo){while(o&&!n&&y!='BODY'){o=o.parentElement?o.parentElement"
+":o.parentNode;if(!o)return '';y=s.ot(o);n=s.oid(o);}for(i=0;i<4;i++"
+")if(o.tagName)if(o.tagName.toLowerCase()!='a')if(o.tagName.toLowerC"
+"ase()!='area')o=o.parentElement;}b=s._LN(o);o.lid=b[0];o.lpos=b[1];"
+"if(s.hbx_lt&&s.hbx_lt!='manual'){if((o.tagName&&s._TL(o.tagName)=='"
+"area')){if(!s._IL(o.lid)){if(o.parentNode){if(o.parentNode.name)o.l"
+"id=o.parentNode.name;else o.lid=o.parentNode.id}}if(!s._IL(o.lpos))"
+"o.lpos=o.coords}else{if(s._IL(o.lid)<1)o.lid=s._LS(o.lid=o.text?o.t"
+"ext:o.innerText?o.innerText:'');if(!s._IL(o.lid)||s._II(s._TL(o.lid"
+"),'<img')>-1){h=''+o.innerHTML;bu=s._TL(h);i=s._II(bu,'<img');if(bu"
+"&&i>-1){eval(\"__f=/ src\s*=\s*[\'\\\"]?([^\'\\\" ]+)[\'\\\"]?/i\")"
+";__f.exec(h);if(RegExp.$1)h=RegExp.$1}o.lid=h}}}h=o.href?o.href:'';"
+"i=h.indexOf('?');h=s.linkLeaveQueryString||i<0?h:h.substring(0,i);l"
+"=s.linkName?s.linkName:s._hbxln(h);t=s.linkType?s.linkType.toLowerC"
+"ase():s.lt(h);oc=o.onclick?''+o.onclick:'';cv=s.pageName+'^^'+o.lid"
+"+'^^'+s.pageName+' | '+(o.lid=o.lid?o.lid:'no &lid')+'^^'+o.lpos;if"
+"(t&&(h||l)){cva=s.split(cv,'^^');vla=s.split(vl,',');for(x in vla)s"
+"._hbxm(vla[x])?s[vla[x]]=cva[x]:'';}else if(!t&&oc.indexOf('.tl(')<"
+"0){s.c_w(c,cv,0);}else return ''");
s._IL=new Function("a","var s=this;return a!='undefined'?a.length:0");
s._II=new Function("a","b","c","var s=this;return a.indexOf(b,c?c:0)");
s._IS=new Function("a","b","c",""
+"var s=this;return b>s._IL(a)?'':a.substring(b,c!=null?c:s._IL(a))");
s._LN=new Function("a","b","c","d",""
+"var s=this;b=a.href;b+=a.name?a.name:'';c=s._LVP(b,'lid');d=s._LVP("
+"b,'lpos');return[c,d]");
s._LVP=new Function("a","b","c","d","e",""
+"var s=this;c=s._II(a,'&'+b+'=');c=c<0?s._II(a,'?'+b+'='):c;if(c>-1)"
+"{d=s._II(a,'&',c+s._IL(b)+2);e=s._IS(a,c+s._IL(b)+2,d>-1?d:s._IL(a)"
+");return e}return ''");
s._LS=new Function("a",""
+"var s=this,b,c=100,d,e,f,g;b=(s._IL(a)>c)?escape(s._IS(a,0,c)):esca"
+"pe(a);b=s._LSP(b,'%0A','%20');b=s._LSP(b,'%0D','%20');b=s._LSP(b,'%"
+"09','%20');c=s._IP(b,'%20');d=s._NA();e=0;for(f=0;f<s._IL(c);f++){g"
+"=s._RP(c[f],'%20','');if(s._IL(g)>0){d[e++]=g}}b=d.join('%20');retu"
+"rn unescape(b)");
s._LSP=new Function("a","b","c","d","var s=this;d=s._IP(a,b);return d"
+".join(c)");
s._IP=new Function("a","b","var s=this;return a.split(b)");
s._RP=new Function("a","b","c","d",""
+"var s=this;d=s._II(a,b);if(d>-1){a=s._RP(s._IS(a,0,d)+','+s._IS(a,d"
+"+s._IL(b),s._IL(a)),b,c)}return a");
s._TL=new Function("a","var s=this;return a.toLowerCase()");
s._NA=new Function("a","var s=this;return new Array(a?a:0)");
s._hbxm=new Function("m","var s=this;return (''+m).indexOf('{')<0");
s._hbxln=new Function("h","var s=this,n=s.linkNames;if(n)return s.pt("
+"n,',','lnf',h);return ''");

Next in the s_doPlugins section of the s_code file you need a couple lines of setup.

s.hbx_lt = "auto" // manual, auto
s.setupLinkTrack("prop1,prop2,prop3,prop4","SC_LINKS");

The plug-in will use 4 variables and a name for a cookie it will set. For this example I am going to use props 1 thru 4.

Next we have the actual code that will appear in the anchor tag that the plug-in will look for. It is a simple name attribute tag of lid and lpos. This is what a link would look like with the code properly formatted.

<a href="my-page.php" name="&lid=Featured Articles&lpos=Left Nav">Cool Article Name</a>

Here’s what it will do. After clicking on a link that contains a lid and lpos (the exact link shown above), this is what you will find in the debugger on the page you land on:
Debugger 1
The plug-in entered the s.pageName value of the page that the click occurred into prop1, the value of lid into prop2, a combination of the prop1 and the value of lid into prop3 and the value of lpos in prop4.

Lets change up what we include in the actual link code. Lets remove the lid from the tag and just use this link:

<a href="my-page.php" name="&lpos=Left Nav">Cool Article Name</a>

This is what we will get from the debugger:
Debugger 2
You can see by not using the lid tag then the plug-in will use the actual anchor text in those positions.

Now lets say you are not interested in capturing the previous pageName value, or the combined previous pageName/lid value. You can just omit those variables in the plug-in setup. Change the code to:

s.hbx_lt = "auto" // manual, auto
s.setupLinkTrack(",prop2,,prop4","SC_LINKS");


You can see I left the commas in there as empty place holders. Clicking the link with that setup and a lid and lpos value will return this in the debugger:
Debugger 3

What about the other links on the page? What if they do not include a lid or lpos value? The plug-in will track those also. Clicking one of those links will return this in the debugger:
Debugger 4
The plug-in will still capture the previous pageName value, the anchor text and the combined values of the two.

I’m sure by now you noticed that auto/manual setting. Up to now its been set on auto. Let’s flip it to manual and click a link on the page that does not include any code. Here is what you will get:
Debugger 5
You will only get the two previous pageName values. If I would have omitted those two variables like I did earlier then it would have not returned anything. If you click on a link with a lid and lpos variables then it will perform the same as if it were set to auto.

If you want to not add the code to the links so you can track all of the links on a page, but you only want to do it on a specific page and not the whole site you can then wrap the code in an if statement like this:

if(s.pageName=='Home'){
s.hbx_lt = "auto" // manual, auto
s.setupLinkTrack(",prop2,,prop4","SC_LINKS");
}

You could also do that using document.location (or a million other ways to identify a specific page).

Since it also grabs the previous page value I no longer need the previous pageName plug-in (useful when using the getPercentPageViewed plug-in).

Enjoy!

Implement Adobe SiteCatalyst in 5 Minutes (or less!)

One of the biggest things I always hear from people considering moving to Adobe SiteCatalyst is the fear of a difficult implementation. It feels to me that most people think they need to implement everything at once, and that is not so. You can just take baby steps and implement small sections at a time. Let’s get started with just a standard implementation to get things going. I’m going to show you how to do a basic implementation of SiteCatalyst in 5 minutes.

First we need to set up a new report suite from the SiteCatalyst Admin Console Report Suite Manager. That can be found by selecting Admin > Report Suites.
Admin Console
Once we are in the Report Suite Manager, select Create New > Report Suite.
Create New
This will open up the New Report Suite setup page. On this page we have two sections to deal with, the first being where we can choose what type of site we are creating the report suite for. I recommend just leaving this set at the default suite type. Since we plan of adding some neat customizations in the future as our analytics needs increase, the default will work fine for us right now.
Suite Type
Next on this page we have five items that need to be filled in. They are all marked with red stars, with the most important being the first one, Report Suite ID. Why is this the most important? Because it the only one we cannot change later. I recommend it should be something you can easily understand what it means. If your site is apple.com then I would just simply choose apple and not something cryptic like 89e7rghv9e7gh (yes I have seen that done before). It actually doesn’t matter what you choose (in case you had your heart set on using 89e7rghv9e7gh), anything will work, but choosing something simple may save some headaches in the future. The Site Title is what you want it to be referred to by in the SiteCatalyst interface, Time Zone is your time zone, Go Live Date is when the site is expected to launch (it must be a date in the future), and Estimated Page Views per Day is just what it says. This number is used by the Adobe engineers to determine what resources to dedicate to your site to ensure everything is recorded correctly. Remember any of these items (except Report Suite ID) can be changed later if you need to. There are other things listed here and you can fill them out or change them if you would like, they are not required in setting up the report suite. Fill out the five required fields, click submit and the report suite is created.
Configure Suite
There are some additional things we need to set up before we start with the actual data collection code. Head back to the Report Suite Manager and find you new suite in the list. Click it to highlight it and then mouse over the Edit Settings link. This will bring up a list of additional settings we can adjust. Remember this section. Later when you get more advanced with your SiteCatalyst data collection, this is where you will go to turn on and off variables for more advanced tracking. There are only two items we need to touch right now, and are going to be located under General.

Under Internal URL Filters you need to set what the domain of your site is. On every single page view there is a referrer. When your visitors go from your home page to your about us page, the referrer to that page is the home page. You do not want that showing up in your referrer reports, so this is where you list out the domain names that you do not want included in those reports. Quick tip: If your site is www.homes.com, and you enter homes.com in the URL filter, it will also filter out sites that have that name included in it, for example newhomes.com or cheaphomes.com. Add a period to the front of the domain name to make sure that only your site is filtered, .homes.com. You can also enter the subdomain with the URL in the filter if your site only lives at a single subdomain, or you can list all of them in the filter.
Internal URL FIlter

Next you want to hit the Paid Search Detection. In here you need to set up a query sting parameter that will be used for your paid search. Even if you do not plan on doing paid search fill this out any way. It is important in making sure your Search Engine and Search Keywords reports work properly.
Configure Suite

We created our report suite, filled out a handful of variables and we are now ready to start playing with the actual collection code. From the Admin Console Home you can find a direct link to the Code Manager, or you can find it from the navigation menu on the left.
Admin Console Home

In the Code Manger we can generate all types of code for what ever we decide to track. From mobile phone apps to flash video players, all the collection code is here. We just want to generate the simple JavaScript Tracking code. Nothing fancy. Select your report suite, set your character encoding or your currency type and click Generate Code. You will get a little pop up warning you to make sure you know what you are doing or the world will end. Just click OK and move on.
Code Manager

Your code is generated now. Take the contents that are under the Core Javascript File tab and save them in a file that you name s_code.js. Take that file and upload it to your web server where it can be accessed from every page of the site.
Code Manager
Now take the contents under the Page Code tab and paste that to every page of your site, right before the closing body tag. In that code you will see the place marked INSERT-DOMAIN-AND-PATH-TO-CODE-HERE. In this position enter the path to the s_code.js file that you previously uploaded.

That’s all there is to it. This should be easily to be accomplished in 5 minutes or less. We setup the report suite, generated the page code and the s_code and added them to the site. This will give us the basic recording of the site traffic, referrals and visitor information. After this is up and running we can go back and add in some additional elements to the s_code file and the page code to customize your SiteCatalyst implementation to your specific site.

Enjoy!

4 Cool Features of Omniture SiteCatalyst 14.7

Today Omniture released the 14.7 version of their analytics platform SiteCatalyst. While most of the excitement will be over the new Dashboard functionality, here are a 4 other new items that I really like.

Trend by day of week
The ability to trend by day of week is a really nice addition. When looking at a report if you trend it over time you will see in the report option’s section a drop down to choose a day. You now have a very easy way to monitor your conversions and custom traffic metrics by any day of the week.
Day of Week

New User Welcome Email
When setting up a new user you now have the ability to send them a welcome email. This email can include things like their login information, and who to contact in your organization for support. I have found this to be extremely useful.
Welcome Email

New User Default Dashboards
While you are still setting up that new user, you now have the option to set them up with a default dashboard. If your organization already has one created that you would like everyone to use, you can set their account up with it right when you create their login.
Default Dashboards

Transfer User Settings
When someone leaves your organization and they have a lot of dashboards and scheduled reports, if you want to keep these items meant having to keep their account around as well. Not anymore. Now you will notice another option to the main user list screen, the ability to Transfer.
Transfer
Now before deleting a user account you can transfer all of their dashboards and scheduled reports to another user.
Transfer

Other features of the 14.7 release include Percentage Graphs in report tables, alerts on classifications, and the ability to duplicate report suite settings. Oh yeah, and those sexy new dashboards.

;) Enjoy!