Archive for the ‘Google Analytics’ Category

Tracking Pinterest with Event Tracking

Now that Pinterest is all the rage, and more sites are starting to put the Pin It buttons next to their images, the next logical step is to track those buttons. Just like we want to know more about the people who share our content on Facebook, Twitter, Google+ and others, we’ll obviously want to do the same for Pinterest.

Pinterest target

We can do this with Google Analytics, but there are two problems:

  1. Pinterest uses an iFrame for their Pin It button, making event tracking difficult
  2. They don’t have a publicly available API, making social interaction tracking a challenge

Today I’ll show you a workaround for the first problem, while the second problem will be the subject for a later post.

Event Tracking on the Pinterest “Pin It” Button

Because the code for adding the Pin It button sets it up in an iFrame, we can’t just add the event tracking code whenever someone clicks on the button. Tracking across iFrames requires the _getLinkerUrl method to transfer visitor and campaign cookies between domains. This also requires cross domain tracking to be set up between the domains. Since you can’t put your own tracking code on Pinterest.com, that option is out.

The other option is to take the code that Pinterest tells you to copy and paste, and hack around it a little bit. That sounds like fun, don’t you think?

You can get the code from the Goodies page on Pinterest. There are two versions – basic and advanced. The advanced code is asynchronous and lets you add the button to multiple images on the same page. If you only have one instance of the Pin It button on your page, then the basic code is all you need.

From the Pinterest goodies page, once you fill in the details (URL of the page the pin is on, URL of the image to be pinned, and description) the basic code will look like this:

<a href="http://pinterest.com/pin/create/button/?url=http%3A%2F%2Fwww.example.com&media=http%3A%2F%2Fwww.example.com%2Fimage.jpg
&description=Awesome%20description" class="pin-it-button" count-layout="horizontal">Pin It</a>
<script type="text/javascript" src="http://assets.pinterest.com/js/pinit.js"></script>

The line I highlighted in bold is the culprit that inserts the iFrame and takes the joy out of event tracking. It pulls in the pinit.js file (you can see the contents here). To restore our event tracking joy, we need to modify the code above to look like below:

<a onclick="_gaq.push(['_trackEvent', 'pinterest', 'pinned']); window.open(this.href, 'signin', 'height=300,width=665'); return false" href="http://pinterest.com/pin/create/button/?url='document.URL' + &media=http%3A%2F%2Fwww.example.com%2Fimage.jpg&description=awesome%20description" style="position: absolute; background: url('http://assets.pinterest.com/images/pinit6.png');font: 11px Arial, sans-serif; text-indent: -9999em; font-size: .01em; color: #CD1F1F; height: 20px; width: 43px; background-position: 0 -7px;" count-layout="horizontal">Pin It</a>

You should recognize the part in green as the event tracking code. This makes sure that a click on the Pin It button gets recorded in GA as an event. (Don’t forget to track your events as goals!) In the example above, we’re setting the category to “pinterest” and the action to “pinned.” You could also include an optional event label for additional info, like the page they’re on or the image being pinned.

The code in blue is what opens up the new window where the user can write a description for the image and complete the pinning process. The code in orange is all for looks – it includes the styling that controls how the Pin It button will look on the page. This information originally comes from a different source – pinit.html (you can see the source code here). That file, however, is usually referenced by the pinit.js file and placed in an iFrame. Since we are no longer including the pinit.js file, we need to include the styling that is lost.

If you’re using the advanced code for the Pin It button (shown below), you’ll need to remove the first part (the section that starts “Include ONCE for ALL buttons in the page”). In the advanced code, this is the part that calls the pinit.js file. Then, you’ll need to modify the second section (the part that starts with ”Customize and include for EACH button in the page”) to look like our color-coded code above.

<!-- Include ONCE for ALL buttons in the page -->
<script type="text/javascript">
(function() {
window.PinIt = window.PinIt || { loaded:false };
if (window.PinIt.loaded) return;
window.PinIt.loaded = true;
function async_load(){
var s = document.createElement("script");
s.type = "text/javascript";
s.async = true;
if (window.location.protocol == "https:")
s.src = "https://assets.pinterest.com/js/pinit.js";
else
s.src = "http://assets.pinterest.com/js/pinit.js";
var x = document.getElementsByTagName("script")[0];
x.parentNode.insertBefore(s, x);
}
if (window.attachEvent)
window.attachEvent("onload", async_load);
else
window.addEventListener("load", async_load, false);
})();
</script>

<!-- Customize and include for EACH button in the page -->
<a href="http://pinterest.com/pin/create/button/?url=http%3A%2F%2Fwww.example.com&media=http%3A%2F%2Fwww.example.com%2Fimage.jpg&description=awesome%20description" count-layout="horizontal">Pin It</a>

 It’s your turn

How are you tracking Pinterest? Do you think Pinterest is even worth tracking? Let us know in the comments!

5 Things We Love About The New, New Google Analytics User Interface

Last week, most of us logged in to a big surprise in our Google Analytics, and it wasn’t a traffic spike, it was the new, new look:

Whoa! Google Analytics, you lookin’ fine.

Now that we’ve had a week to digest the changes, here’s a few of our favorite things that Google has added in this substantial update.

  1. Sharing of Custom Reports and Dashboards has never been easier.

    I think this most affects people who work with clients or have teamwork among analysts, but if you’ve ever wanted to share a custom report with someone before, it was a pain (usually ending up in the wrong profile), and the ability to share Dashboards was just nonexistent. The new interface lets you choose what profile to apply the dashboard/filter easily.
  2. Less flash!

    You can now view Google Analytics on your iPod/iPad and see the line charts. I suspect this also explains why GA feels a little peppier. They are most likely phasing out all flash in favor of HTML 5. (A peek into the source code shows that graphs now come from an Iframe which is rendering things with scalable vector graphics)
  3. Toggle Buttons are More Clear.

    A bunch of features that have been in GA for some time are more apparent now, thanks to a clean new layout of buttons. For me, the Compare Metric and Plot Rows options are much more obvious now. I also really like the Day/Week/Month toggle, it seems cleaner and is definitely less buggy then the old drop-down.
  4. Sampling Slider.

    While you still can’t turn off sampling (unless you use GA Premium), at least it’s possible to show your customers that sampling can be pretty accurate (or inaccurate) depending on the amount of sampling. I’ve played around with this to see what percentage Transaction data gets the most inaccurate. I’m not sure why anyone would want .02% of their data sampled in exchange for speed, but it’s possible now.
  5. Pretty Thumbnails.

    This small bit of eye candy makes the sections in GA really pop out, and makes the overall tool look a little more exciting. Although Daniel Waisberg makes a great point that the $ symbol should be by goals instead of Advertising, but I guess Google doesn’t see it that way!

Still using the old GA? We’re offering a free online webinar to help with the transition. Sign up now, we’re limiting this webinar to the first 90 people.

How a Nonprofit Can Best Use Google Analytics

Recently, the brilliant Brian Honigman wrote a blog post here at LunaMetrics about How Nonprofits Can Get The Most Out Of Foursquare which got me thinking about how a nonprofit could get the most out of Google Analytics.

There are some estimates that 60% of websites don’t use any type of Analytics tracking, and that the number is even higher for nonprofits.

We’re not sure why this is. It could be that some people view tools like Google Analytics as very commercial and profit oriented, and therefore something that a nonprofit wouldn’t, or even shouldn’t use. It could be that Nonprofits tend to have passionate people who wear more hats than they would at a commercial enterprise, and they’re doing their best, but data analysis isn’t in their wheelhouse.

(If you’re a Nonprofit and aren’t using Google Analytics for another reason, drop us a comment after this post and let us know why! We’re honestly curious.)

Sometimes people at nonprofits feel that this sort of analytics and tracking is about “selling” and that as a nonprofit it’s somehow gauche to look at their websites as places to track “conversions”, however all the major Nonprofits do just that. There are plenty of things you can and should track as far as Goals and Conversions on your sites. You might not be selling anything, but you’re still engaging people in calls to action.

How Can you Use Google Analytics to track a Nonprofit goal?

If you're losing it, just hold on, it gets better

If you're losing it, just hold on, Google Analytics will make it better

Well let’s look at something like “Donor Activity”. You might have a place on your website for people to donate money. With Google Analytics you can parse all those donations with various other data points to help you increase your Donor Activity.

For instance you can see where they came from, whether it was a Google Search, or an Email, or a Facebook page, or another website. You can then compare where they came from with donation patterns. Maybe certain emails generate higher levels of donations than others, which can help you tailor your email campaigns to better grab and engage your network.

If they arrived via an organic Google Search you can see what keywords they used, and you can take those keywords and tailor your Search Engine Optimization (or SEO) to get even more people to visit your site. (And hey if you’re interested in SEO for Nonprofits you should check out our SEO Training Day on April 2nd, 2012 in San Francisco, which we’re offering in conjunction with the Nonprofit Technology Network’s annual conference. A full day of nonprofit specific SEO training)

You can look through your visitors and see what pages they looked at, how long they stayed on your site, and which content engaged them, or which content “bounced them” from your site. You can what pages were more likely to get people to donate.

There are so many things you can do to track and improve your efficacy with specific conversions, and so many different types of conversions you could track besides Donor activity.

  • How many people are hearing and reacting to your message?
  • How many people are visiting your site when you post something on Facebook, and what do they do on your site?
  • How much information do they read?
  • Are there better ways to get your message out?
  • Do people respond better when they come to your site from various social media, or from email campaigns?
  • Which campaigns?
  • Which methods?
  • Which referring websites?
  • Are you increasing your networking and email lists?
  • What methods work best for that?
  • Are you increasing attendance and participation at your events, fundraisers, participation and number of people served by your Nonprofit, or the number of volunteers or volunteer hours?

There are plenty of things that Nonprofits can and should track to help them improve their entire organization.

Why Should A Nonprofit use Google Analytics

There are a number of reasons why a nonprofit would want to use Google Analytics over other software. First of all it’s one of the most sophisticated analytics packages available. It allows you to do more types of tracking, segmentation, conversion tracking, than other pieces of software, sometimes offering more options in certain areas than even paid solutions.

Which brings us to the second reason: It’s free. Nonprofits don’t necessarily need to pinch every penny, but if one of the most sophisticated analytics software packages is available for free, you have to question whether it’s worth paying tens or hundreds of thousands of dollars for a paid solution, that might not give you any additional functionality that you would use. It’s also a hosted solution, which means that Google hosts the data. This frees up your IT department, if you have one, from maintaining a server devoted to your analytics, and simply let Google take care of that.

In addition, it’s easy to use. Google provides free tutorial videos that are quite excellent  and there are plentiful resources, websites, and books that can help. On top of that there are opportunities for training both on site, as well as  at the Google approved training programs the “Seminars for Success”  which are offered by only a few Google certified trainers.

All in all it’s a solution that makes sense even for large and reputable Fortune 500 companies, down to the local Mom and Pop shop, as well as Nonprofits.

Getting Started – Step 1: Don’t Panic

Don't Panic (From the Hitchhikers Guide to the Galaxy)Yes, I stole that from Douglas Adams.  It’s applicable though, and something you should hold onto before we go any further. The world of Analytics might be scary, particularly if you’re not technical, but I promise you, that if you follow a few simple steps, you’re going to find that Google Analytics is a tool that can really help your Nonprofit in many ways. So whether you’re taking the initiative or your boss told you to get this done… Don’t panic. Don’t worry. It’s honestly not painful.

Step 2: Check out Google for Nonprofits

If you aren’t already using it, I highly recommend you head over to Google for Nonprofits and sign up. There are a number of benefits, including free or discounted versions of Google Apps, Free (with a catch) Adwords advertising, Premium branding and increased uploads on YouTube, Free licensing for Google Earth, the Maps API and more. If you are a Nonprofit and you’re on the internet, you have no reason not to sign up for this. They also provide a handy checklist for Nonprofits entitled “12 actions to expand your reach“ which gives you great ideas of things you can do to help your Nonprofit reach out online.

And guess what the very first item on their list is?

Step 3: The Most Technical Part

Google Analytics Asynchronous Tracking Code

Google Analytics Asynchronous Tracking Code

It’s like ripping a band-aid off, and it’s really not that scary. You need to get the Google Analytics Tracking Code  installed on your website.  To do this first you need an Analytics account. Head over to Google Analytics and create a new one.

I recommend that if you’re doing this for your Nonprofit, you should create an administrative account in Gmail first, if you don’t already have one. This way you don’t do it on your personal account. Don’t worry. After you create your new administrative account, you can give your personal account admin privileges to the analytics so you’ll be able to access it without constantly changing your login.

So create your new “Nonprofitname@gmail.com” account, and then create the analytics account using that account.  It’s quick and relatively painless, and at the end the Google Analytics page provides you with the code to use which you can have your developers cut and paste onto your webpages. OR if you’re using a WordPress site there are a variety of plugins that will help add the code to all your pages for you. I recommend Google Analytics for WordPress if you go that direction.

Be sure to install the newest Asynchronous code and place it in the <head> section of your website code for the best tracking results.

Once the tracking code is installed I recommend reviewing a number of our blog posts including Phil Anderson’s excellent series on increasing conversions from website traffic starting with The Infinite Conversion Loop  and moving onto 10 Things to Check in Your Google Analytics.

Step 4: Get Addicted To Your Data

Be careful! If you haven’t had Google Analytics before on your site, it can be a bit addicting to track your numbers, checking day to day… Before you know it you’ll be talking to someone about Custom Reports and they’ll just give you a blank stare in return. Don’t worry! This is normal.

So what can a Nonprofit do to really make use of that data. Well a lot more than I can put in a single blog post, but here are a few fun starter ideas.

1 – Google Analytics in Real Time: Watch your data update within seconds.

Real Time Google Analytics

Are you placing a television commercial, or participating in some sort of event and want to see immediate data? Well with Google Analytics you can watch that data come in in real time. It’s unfiltered data, so if you have a large number of filters on your profiles, it won’t be totally accurate to a profile, but you can see those hits. If you normally only have 10-20 people on your site, it can be exhilarating to see an immediate and real time impact of your marketing efforts and watch people actually click through your site, submit forms, donate money, etc.

Google Analytics in Real Time: Watch your data update within seconds.

2 – Tracking Your Marketing Campaigns

It’s amazing how many people, even those who already have Google Analytics installed don’t use Campaign tagging. Campaign tagging allows you to parse your data based on your marketing efforts. Sending out an email? You can see which email specifically did better than another. Posting on social media? Does Twitter or Facebook generate more interaction with your information? By using Campaign tagging in all your links you can find out what efforts you are doing are working better than others, and help tailor your ongoing marketing efforts to attack those channels that really work for your Nonprofit better than others.

4 Steps to Better Campaign Data in Google Analytics

3 – Tracking your SEO Progress

Keywords-Report

SEO seems like magic sometimes, and people want to see what kind of success their SEO campaigns have, or if it’s even worth their time.  However Google Analytics provides some great ways to track how many people from which keywords found which pages, and their change over time. You can use it also to track your referral traffic and link bait. If you’re doing SEO for your nonprofit website, and you should, then you can use your Google Analytics data to help in your efforts to improve and gain even more traffic. It’s useful to see the top 20 words and phrases that people search for your website and organization on. What do people want from you, and what are they looking for? This lets you develop content for these terms, and catering to your users helps you build traffic.

You can even look at the bounce rates for keywords (bounce means that the visitor leaves the site without interacting with it at all). Then by seeing keywords with high bounce rates you know to avoid those keywords, because they are bringing in visitors who aren’t finding what they want on your site. OR if it’s a keyword you do want to emphasize then maybe you need to look at your website to see how you can better grab those users on your site who come in via that keyword.

How to use Google Analytics to Track SEO Progress

4- Tracking Your Social Media Engagement

Social-Plugin-Tracking1Google Analytics comes pre-installed tracking Google+ sharing, but with some extra tweaking you can track which of your users are logged into Facebook, Twitter, etc while they’re on your site. With some additional page code you can track how many people visit your Facebook pages, how many “Like” your website or specific page content from within your website, etc. Social Media is a big way for nonprofits to communicate with their audience, so it’s very important to track their engagement with your website, rather than relying simply on something like Facebook’s internal Insights. By tracking engagement on your pages, you can tell more about your users behavior, as well as which social networks to target, which content grabs users better, and more.

Tracking Social Media Engagement in Google Analytics
Event Tracking or Social Tracking or Both?

5 – So much more

You can view high bounce rate pages, and review how people got to those pages, and determine if you need to change the content, the keywords, or anything to better retain users to those pages.

You can ensure that the most viewed pages include calls to action, so that you are getting your goals into people’s faces as much as possible. People can’t convert if they aren’t offered an opportunity to do so.

You can do the same on high exit rate pages, and find ways to keep people on your pages rather than pushing them away. Give people an easy out on a donation page for instance to somewhere else on the site, and make them feel ok with not donating.

Use Goals. Determine what you want to do on the site, and set Goals in Google Analytics so that a form has a conversion rate. A donation process has as goal and a funnel so you can see where you lose people along a process. Use the goals in conjunction with other data to determine if some users are more likely to convert than others and leverage that information.

Moving Forward with Google Analytics as a Nonprofit

We’ve only brushed the surface here.  Really anything you’re doing on your site you should be tracking to see how you can make it better. Always be testing. Always be checking your data. Always try and improve and do better, and Google Analytics is a great tool for nonprofits to use. It’s powerful, it’s free, and it’s fun to use! If you aren’t leveraging Google Analytics in your efforts on a daily basis, then it’s time to start.

How to Track a Moving Target – Employee Data in Google Analytics

Recently a client asked us to help them do a better job tracking employee visits to their website. For many websites this is a relatively small segment of traffic and often comprises visits from the dev team. But this particular client, like many of our nonprofit clients, has a staff that uses the organization’s website regularly over the course of a normal workday. And so it’s especially important to separate external and internal traffic.

Moving Target

The usual advice for removing internal traffic from your Google Analytics data is one of two methods. Either set up a filter based on your IP address (or range of addresses). Or if your organization is large enough to be its own ISP (Internet Service Provider), then the filtering is even easier.

Internal Traffic is a Moving Target

But neither of these methods address how your employees visit your website on their mobile devices or laptops. They might be out of town for a business trip on a hotel network, at home on their home network, or even on the Wi-Fi at the local coffee shop.

And we all know this is a rapidly growing segment of visitors, especially as more and more people use tablets. Your internal traffic is literally a moving target.

Cookies for Everyone!

Which brings us to a third method, having your employees set a visitor cookie to identify themselves. Google Analytics has a field called User Defined that you can use to filter internal traffic. User Defined is the older version of what are now called Custom Variables – but those aren’t available yet for filtering.

Because a visitor cookie is specific to a computer and browser, your employees can identify themselves on every device they normally use. Simply have them visit a special page that will set the cookie for them, and ask them to visit that page one time on every device and every browser.

Remind Staff to Visit the Cookie Page

After that you’ll be able to identify your internal traffic and filter it, regardless of their IP address or ISP. Of course, if they delete their cookies, they’ll need to visit the page again. So you could remind them periodically, “Hey, here’s that URL we need you to visit. Help us keep our analytics data clean.”

To make it even easier, here’s what the code looks like. Just insert your UA-number where I have UA-XXXXX-YY and publish the page.

 

<html>
<head>

<title>Remove My Internal Traffic from Google Analytics</title>

<script type="text/javascript">
              var _gaq = _gaq || [];
              _gaq.push(['_setAccount', 'UA-XXXXX-YY']);
              _gaq.push(['_setVar','employee']);
              _gaq.push(['_trackPageview']);
              (function() {
                var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
                ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
                var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
              })();
</script>

</head>

<body>

<h2>Remove My Internal Traffic from Google Analytics</h2>

Visit this page on every computer, tablet, and smartphone, and for all browsers you use on those devices.<br>

</body>
</html>

Create the Filter

You could also choose a different value for _setVar; where I have ‘employee’ you could insert any identifier you like. Remember to create the exclude filter using this identifier and apply it to a test profile – make sure it’s working before applying it to your main profile.

internal-traffic-filter

Check Your Profiles

You may also want to create a new profile that includes only internal traffic. Or cross-check everything against your unfiltered profile. (You do have a completely unfiltered profile for troubleshooting, right?) With a glance across profiles you can see that the data is in fact being sent to GA and appears in one profile, while being correctly excluded from another profile.

Tracking employee visits is essential for nonprofits and other organizations with staff who use the website regularly. Adding to the complexity are employees working remotely and the increasing use of mobile devices. The cookie page is a relatively easy to implement solution. What obstacles have you encountered and what methods do you find most accurate for capturing employee data? The comments are yours.

Have you worried about employee visits muddling your analytics?

Tracking Social Media with Google Spreadsheets – Part 1

This is part 1 of a 2-part series on using Google Spreadsheets to make social media measurement easier, quicker and almost completely automated. When you’re done reading this, Part 2 awaits!

Google Docs and TwitterThere are two problems I’m going to solve for you today:

1. Tracking social media is hard
2. You don’t have time to track social media

Tracking social media is hard

Let’s tackle the first problem. Yes, tracking social media is incredibly difficult. There are a million things you can track, including content on your site that’s being shared, people that are mentioning your brand or products online, tweets, shares, likes, pluses – you name it. It seems like everything is social these days, which makes tracking it kind of like counting grains of sand as they fall through your fingers.

But you have to start somewhere, and the easiest place to start is on your own site. With your own content. Which raises a number of other tracking issues. For instance, there’s a difference between tracking how many people click the social sharing buttons on your pages vs. how many people click on the links in your tweets vs. how many people copy and paste your URL and share it on their own (and how many people click on the links in their tweets/shares/posts etc.).

Again, you have to start somewhere. Today, we’ll start with tracking how many people click on the links to your content that you share on your social networks. This is actually rather easy, and I’ve broken it down into 5 steps:

  1. Copy the URL of the content you’re sharing
  2. Paste that URL into the Google Analytics URL builder, along with the following:
    1. Campaign Source – twitter (or facebook, linkedin, googleplus, etc.)
    2. Campaign Medium – social
    3. Campaign Name – blog (or something that signifies the type of content you’re sharing)
  3. Take the full URL (for example, http://www.yoursite.com/awesome-blog-post?utm_source=twitter&utm_medium=social&utm_campaign=blog) and shorten it with Bit.ly (because every character counts when you only have 140)
  4. Share that shortened link on the specific social platform that you identified for the utm_source
  5. Rinse and repeat steps 2-4 for every social network you want to use

Wondering why I chose those source, medium and campaign names? Read up on this refresher for campaign tagging in Google Analytics. Doing the above will make it very easy for you to get insights into which social media channels are worth your time. Just go to Traffic Sources > Sources > Campaigns, click on blog (or whatever campaign name you chose), and do a little happy dance when you see a report like below:

Measuring social media - campaigns report

Notice, I ditched the standard data table view for the sexy comparison view.

I don’t have time to track social media

It’s true, the steps above take time. In fact, it used to take me at least 15 minutes to add the campaign parameters, shorten the links, and then share them on the various social networks. I can’t stand wasting time doing repetitive tasks that can be easily programmed. Thanks to Tom Critchlow’s post on how to build agile SEO tools using Google spreadsheets I can choose to spend my time building tools that do the repetitive nonsense for me. I’ve been using Google spreadsheets to hack together tools very quickly to do all sorts of things, including automating the task of tagging URLs with campaign parameters and shortening the links.

Social media tracking tool

I’ve done the dirty work for you, so go grab your copy of the spreadsheet here. Once it’s open, go to File > Make a copy so you can edit the spreadsheet (you may need to sign in to your Google account  - even if you were already signed in). All you need to do is enter your Bit.ly username and API Key (you can find that here) on the ‘Technical Details’ tab, then enter the URL of whatever page you’re sharing and voila! This tool takes your URL, appends campaign parameters for Twitter, Facebook, Gooogle+ and LinkedIn and shortens each one for you so you can quickly and easily share those links. How you spend the 15 minutes you saved is up to you, but please take just 2 of those minutes and tweet this post. I don’t ask for much :)

How it works

This is for those of you interested in peeking behind the curtain to see how this works. The real magic happens on the ‘Behind the Scenes’ tab. You’ll see that cell B3 pulls in the URL that is typed in on the main tab. Columns C, D, and E hold our values for utm_source, medium and campaign.

Behind the Scenes tab - social media measurement tool

In cells B8 through B11, you’ll see a formula like this:

=concatenate($B$3, "?utm_source=",C3, "%26utm_medium=",$D$3, "%26utm_campaign=",$E$3)

This simply takes the URL in B3 (the page that you’re sharing) and concatenates that with the values for source, medium and campaign. One thing to note is that instead of a “&” I’ve used “%26″ – which is the URL encoding for the ampersand character. This is necessary for the Bit.ly API.

In cells B13 through B16, we take the campaign tagged URLs from the previous step and run them through the Bit.ly API. The following formula accomplishes that:

=concatenate(importdata(concatenate
("https://api-ssl.bitly.com/v3/shorten?login="&'Technical Details'!$A$4&"&apiKey="&'Technical Details'!$A$7&"&longUrl="&B8&"&format=xml")))

The important thing to notice in the above formula is the use of the importdata function. It lets us pull in the results of the Bit.ly shortening operation. For more details, check out the Google spreadsheet function list.

Finally, back on the main tab (ShareMe!), the Bit.ly shortened links are pulled in from the ‘Behind the Scenes’ tab using the following formula:

=mid('Behind the Scenes'!B13, (find("<url>",'Behind the Scenes'!B13)+5), 20)

So if you want to add more social networks (or change the ones listed), you’ll need to go into the ‘Behind the Scenes’ tab and make your modifications there.

Stay tuned for Part 2

Next time, I’ll show you how to use scripts within Google Spreadsheets to detect when you’ve published a new post, and automatically send an email with the shortened links.

In the meantime, let me know if this is helpful, or if you have other ways to streamline your social media workflow. The comments are yours!

 

Where Should The Google Analytics Tracking Code Be Placed?

Before I even start talking about this, let’s go to code.google.com for the official recommendation on where someone should place their Tracking Code on their webpages…

The Analytics snippet is a small piece of JavaScript code that you paste into your pages. It activates Google Analytics tracking by inserting ga.js into the page. To use this on your pages, copy the code snippet below, replacing UA-XXXXX-X with your web property ID. Paste this snippet into your website template page so that it appears before the closing </head> tag.

Google Analytics Asynchronous Tracking Code

The Google Analytics Asynchronous Tracking Code

Ok! Thanks for reading, see you next time!

Just kidding, of course it’s not that simple.

So seriously, where should I put my Google Tracking Code?

We actually get people asking us about this a lot. It’s one of the first items in our audits that we look at. What version of the tracking code are you using, and where is it on the page. There are plenty of variations, but the most common one if it’s not completely up to date, is having non-Asynchronous (or ‘traditional’) tracking code, which is placed at the bottom of the page.  So when the first item in our audit says “We recommend you update to the Asynchronous tracking code, and move it’s placement into the <head> of your document, rather than at the end of the <body>” people get worried.

Is it bad to have the Google Tracking Code at the bottom of the page? I read that you should put it there at the bottom, rather than up in the head because it makes your site faster.

Headless fish bodies

Should you place the tracking code in the <body>?

The quick and dirty answer is that yes it’s safe to put the new code really anywhere on the page, and for 99% of users, you’ll want to use the Asynchronous code and put it in the head of your document. There are a few exceptions/alterations which I’ll note in a minute.

The less quick part of that answer is that it WAS bad to put the traditional Google Tracking Code in the head of your webpage in the past, so if you read some book or blog purporting to speed up your website extolling the virtues of putting the Google code at the bottom of the page, then they may have been correct once, but they aren’t anymore. The speed of the internet, and all that jazz.

Google released the Asynchronous Tracking code on December 1st, 2009. Prior to that point all we had was the traditional code, and it worked like most other basic JavaScript code. That is to say that it would go one line at a time. So when your browser loaded up a line of code, it would load that line only, and then wait till that line was fully loaded. Then, and only then, would it move to the next line, and then load that line, etc. Like a single conveyor belt. The problem with that design though, is that if you ran into a snag the entire page would hang. So if the Google Tracking Code back then was placed at the top of your webpage in the head of the document, then the speed your site loaded was partly determined by how quickly Google sent you that code. If it took Google 10 seconds to send you that code, that was 10 more seconds your visitor had to wait to view the page. That’s why it was recommended to put that code at the very bottom of the page. That way if it stalled in loading the files from Google, at least your page was loaded first.

The Asynchronous code though works differently. Rather than say a SINGLE conveyor belt, now there are multiple ones, and the rest of your page can load up regardless of how long it takes to retrieve data from Google. The tracking code loads up on its own conveyor, while the rest of your site loads on another.

And on top of that the Asynchronous code is designed to be downloaded only once from Google, and then it’s served from your cache (i.e. it’s saved on your computer and you won’t have to download it again), which makes it that much faster.

You lost me poindexter, what does that mean for me?

It means the asynchronous tracking code averages a 5% improvement in tracking data, with some sites showing 10 and even 20% improvement in their data. If you use Adwords, it closes in on 100% accuracy with the asynchronous code.

The asynchronous code is faster, and therefore you get better more accurate numbers as to how many people are actually visiting your site.

What if I have events or things happening on the page, where I need to record user actions, and the tracking code hasn’t loaded yet?

Well, that problem would also happen if you had the non-async code firing at the bottom of the page, but with async it’s much better. Even if it takes time to load the ga.js file from Google, it’s already set up the tracking variables on the page, and will store the events you perform before the actual file is loaded. Once the file loads, then all the events backlogged will be sent to Google. It’s not PERFECT, but for the most part it will capture events that happen prior to the Google tracking code has even finished loading, and send them after the code has been loaded.

So do I need to move it to the head of all my pages? I have a lot of pages, and that’ll take a lot of time.

Fish heads

You can put your tracking code anywhere, but it's better in the <head>

Nope. You can put it anywhere you want really, and It’ll run anywhere on the page whether it’s in the head or the body.  It’s recommended you put it in the head though, so it can be as accurate as possible.

You see, the Pageview is recorded only after that code is loaded up. So the sooner you load the code, the sooner that Pageview is recorded. Let’s say you have a big blog page, and it’s a slow loading one, taking even 10 to 20 seconds to load everything up. If your Google Code doesn’t start until the end of the page, it can get held up, just like the old non-asynchronous code used to hold up OTHER lines of code. Except now it’s holding up the tracking code. If a visitor to your site hits the page, and then leaves it before the tracking code fires the Pageview, then you lose that visitor. They now become a new direct visit to whatever page of the site they landed on. This can make all sorts of data on your site incorrect.

So it’s best practices to use the Asynchronous code in the head of your page, it won’t slow down the rest of your page from loading, and by having it there it won’t GET slowed down by the rest of the webpage either, so it’ll fire sooner, and you’ll get a more accurate count of what pages your visitors visit.

So what are the exceptions? When is it BAD to run the tracking code up in the head?

I mentioned before that there ARE a few exceptions. One is if you’re setting custom variables on the page.

If you set a Custom Variable on your webpage then it will essentially sit on your page, waiting for either a pageview to be tracked, or an event to be called. If you set a custom variable on a page and don’t track a page or an event after it, that custom variable will NOT get passed to Google. Sometimes you might not be tracking any events on a page, but you’ll want to set a custom variable. Because of how code is delivered, it’s possible that custom variable might only get generated AFTER the head document.  Usually a page can be coded so that these variables can be determined before the HTML is delivered and then you can have the custom variables created in the head of the document as well. Maybe it could theoretically be put in the head, but the developers didn’t build the page that way, and you’re not willing or able to have them redo everything. In those cases you can set a Custom Variable anywhere on the page, and then rather than tracking the pageview in the head of the document, you remove this line:

_gaq.push(['_trackPageview']);

from the Asynchronous code, and then insert it later in the page wherever you like, after the custom variables are set. That way the code loads up, it doesn’t interrupt the page load, and you can then track custom variables on the page itself anywhere they appear, as well as retaining the benefit of loading the tracking code early.

HOWEVER, this can also reduce accuracy, because if a user navigates away before that trackPageview is called, then you’re facing the same problems that the traditional code presented in the first place. Another option would be to use Event Tracking. An event being fired will also submit that queued custom variable, so you could fire an event tied to that custom variable. Essentially a throwaway event.

_gaq.push(['_setCustomVar',1, 'Status', 'Logged In']);
_gaq.push(['_trackEvent', 'Custom', 'PageLoad', 'Setting Logged In State',0,true]);

A couple notes on this:

First we’re setting the Custom Variable, we’re assigning it to key space 1 (of 5), and we’re calling it Status, and setting the value to Logged In. That’ll sit there until an Event or Pageview is tracked.

So we do the event. We set it to a Custom category group, we definte the action as PageLoad because a user isn’t specifically interacting with this event. Then we set the Label as to what the event is doing. We add a 0 to the value (you don’t have to add an actual value there if we’re not using it, but I’m personally uncomfortable passing nothing). We also then set the non-interaction value to true. This is also key if you use an event here. If you don’t set it as true, then the event is considered a page interaction, and it will affect your bounce rate from the landing page. Essentially rather than someone coming to your page looking at it and hitting the back button being considered a ‘bounce’ It would not be considered one because the user ‘interacted’ with the site. So we set this to true, so that isn’t considered in that respect.

But wait, I read something on Google’s own support pages that said I shouldn’t do this?

You mean this page?

Yeah, you don’t believe everything you read, do you? That’s old outdated support information.

So if we update is it going to change my data? Like am I all of a sudden going to see more pageviews or something?

It’s possible. It depends on your site, where the code was, what sort of speed and pageload times you have. By updating you should see the data you’re getting change, maybe a little, maybe a lot. But it’ll be MORE ACCURATE data. Here we tend to side with getting the data to be as accurate as possible, even if there is a bit of a break in the levels of reporting.

If I don’t update, will my site continue to track data?

Sure. It probably won’t be as accurate, but depending on your site it’s conceivable it’s not a huge data difference. The main functions are all loaded from the same place, the ga.js file. The main difference is how it loads, how fast it loads or is even cached in your browser, and therefore the accuracy of your data.

So what should I do?

If you’re NOT using the up to date Async code you should update to using that. You’ve really got to have some serious things going on to NOT update. Does it need to be in the head of the document? No, it won’t kill you to have it at the bottom of the page, but if you CAN move it to the top, then you should because it’ll be faster and more accurate. If you don’t know of a reason to keep using the non-async code at the bottom of the page, and you’re not using custom variables… Then really there is no reason to NOT update it and move it to the top of the page. You’ll have more accurate data, you’ll get newer and better tracking features, and more. Come on. Everyone’s doing it.

How to Track Conversions for Both Internal and External Campaigns

After you learn about campaign tagging for Google Analytics, you may be excited that you can add all that extra information to a simple little link – so excited that you want to put campaign tags on every kind of promotional link that leads to a web page on your site. But there’s one kind of link that should never get campaign tags. You should never put GA campaign tags on internal banners or on-site promotions that lead from one page of your site to another.

Why You Shouldn’t Use GA Campaign Tags for Internal Promotions

Imagine this sample scenario: A visitor clicks an email campaign link from your latest marketing effort and lands on your site. Google Analytics records the traffic source and starts collecting data for the visit. Of course you hope that the visitor will continue to view pages on your site and maybe even convert on an important goal like registering for an upcoming conference or buying your latest e-book. When they do, you’ll be able to attribute that conversion to the campaign and evaluate that campaign’s success.

But what happens if the visitor clicks an internal banner with campaign tags before they convert? Google Analytics records a new traffic source and starts a whole new visit. So now you have at least two problems: You’ve split what was really one visit into two visits, skewing your data. And you can’t tie the original email link directly to the conversion, because the conversion happens in a separate visit.

To track internal promotions without splitting visits and losing credit for conversions, try one of these instead:

  • Add your own campaign parameters (not GA campaign tags) to the links and view the data in your Content/Pages reports
  • Use event tracking when a visitor clicks an internal banner or promotional link and view the data in your Content/Events reports

Alternative #1: Add Your Own Campaign Parameters

The first method involves making up your own tags, ones that GA won’t recognize and will pass right along into your Pages reports with the rest of the URL. Instead of utm_source or utm_medium, for example, you might simply add something like “from=promo” to the target link:

http://www.anything.com/buy-ebook.html?from=promo

Or you could use a more detailed scheme if, for example, you run internal promotions with many types of links in different places. So you might have one parameter similar to campaign name, like “campname=e-book”, and another parameter that describes the links, like “camplink=home-page-banner” or “camplink=side-nav-feature”:

http://www.anything.com/buy-ebook.html?campname=e-book&camplink=home-page-banner

http://www.anything.com/buy-ebook.html?campname=e-book&camplink=side-nav-feature

As long as you stay away from Google Analytics utm parameters, these types of URLs will appear in your Content/Pages reports and you can tell by the number of pageviews exactly how many times a visitor clicked the tagged link to arrive there.

Internal campaigns in the Content Pages report

Alternative #2: Use Event Tracking

The second method involves adding a bit of code to the link on the page. Inside the anchor tag (a href=”…”) include an onclick event like this (a href=”…” onclick=”…”). And in the onclick event, add the event tracking code using an event category and action like “internal promo” and “home-page-banner”:

onclick="_gaq.push(['_trackEvent', 'internal promo', 'home-page-banner', this.href]);"

After the event category and action it’s a good idea to include the optional event label. For the label you can simply write the target (href) of the link, using this.href.

View this data in your Content/Events reports by drilling into Top Events through the “internal promo” category, where you can see the how many times someone clicked each of your different internal promotional links.

Internal campaigns in the Top Events report

Combine with Custom Variables for Goal Data

Okay, so where’s the goal data? You may have noticed that Google Analytics has Goal tabs in Traffic Sources reports, but not in Content reports. The whole point of these alternatives was to keep your original traffic source intact so you could tie it to a conversion. But you probably also want to know how well your internal promotions lead to conversions, too, right? Of course you do.

Well, there’s another set of reports that has Goal tabs, where you can combine conversion data with a set of dimensions that you define, and that’s the Audience set of reports. You can write a custom variable with the parameters or event data you created in either alternative described above. And then you can easily compare goal conversion data in a single table that lists all your internal promotions.

Conversion Data in Custom Variables report

The thing to remember when writing custom variables is that the data needs to piggyback on a _trackPageview or _trackEvent call.

For the event tracking alternative, add _setCustomVar to the onclick event, like this:

onclick="_gaq.push(['_setCustomVar', 1, 'internal promo', 'home-page-banner', 2]);_gaq.push(['_trackEvent', 'internal promo', 'home-page-banner', this.href]);"

For the other alternative where you make up your own campaign parameters, I suggest adding _setCustomVar to the page that’s the target of the link, right before the usual call to _trackPageview. You can use a little Javascript to read the URL and write the custom variable according to the campaign parameters that appear there. For example, if the URL is:

http://www.anything.com/buy-ebook.html?campname=e-book&camplink=side-nav-feature

The resulting custom variable code (placed before the call to _trackPageview) could be something like this:

_gaq.push(['_setCustomVar', 1, 'e-book', 'side-nav-feature', 2]);

In both cases I’ve set a session-level custom variable (indicated by the number 2 above), and I’ve set the custom variable to slot number 1 (out of 5). If you are already using that slot then you’ll need to assign it to another one. Read our post about how to keep track of custom variable slots and scopes for more guidance.

No More Split Visits

Avoid the split-visit problem. Keep visit data together by keeping internal and external promotions separate. Track your external campaigns with GA’s utm parameters and try one of the above alternatives for internal campaign tracking. And tie both external and internal promotions to conversion data to evaluate the success of each.

What methods do you use for tracking internal promotions? And how do you tie them to conversion data? Please share in the comments.

Google Analytics Configuration Made Easy

Create an account, copy the code, and paste it on every page of your site. Easy, right?

Not so fast.

If you’re just starting out using Google Analytics, you may not be aware of all the advanced code implementations available, much less how to modify the code for your needs. But if you are tracking across subdomains or multiple domains, or if you want to do some advanced tracking with events that’s exactly what you need to do.

To make matters worse, navigating through the labyrinthine administrative interface to find the tracking code snippet can be somewhat daunting. Especially if you’re used to the old version of the interface. And although the code wizard in GA does include several configuration options, the instructions are neither complete nor easy to follow for beginners.

Google Analytics Configuration Tool by RavenTools

To solve these problems, the team at Raven Internet Marketing Tools has built the Google Analytics Configuration Tool. (Full disclosure: we provided consulting on some of the technical details for this tool, so of course we’re thrilled to see it’s birth). They just launched this free tool, aimed at simplifying the process of configuring your Google Analytics. Out of the gate, there are several specific situations they provide instructions for, including:

  • One domain with subdomains
  • Multiple domains with subdomains
  • Site search setup
  • 404 error page tracking
  • Event tracking
  • Setting up goals
  • Tracking Facebook page and referrers

There’s also a URL  builder for tagging your URLs with campaign parameters.

Besides just giving you the snippet of code, the GA config tool leads you step by step, asking questions about what you’re trying to track and then providing the code and instructions of what to do with it. It also provides the code in either asynchronous or the traditional ga.js.

This is a godsend for people who don’t deal with GA on a daily basis. Trying to figure the correct code configurations has generally meant wading through a sea of posts in the help forums, where the information is often outdated and inconsistent. This tool takes the guesswork out of the setup, letting you focus on what matters – your data!

Coming from the folks who also created the Schema Creator (for creating structured markup for your site), not to mention their core suite of internet marketing tools, this will be an essential addition to many digital marketers’ arsenals. They’re already working on adding functionality to help with regular expressions, setting up filters and other points of analytics confusion.

Go try this tool out and let us know what you think. Are there any other GA-related instructions you’d like to see added? What is it about GA that is most confusing to you?

The comments are yours.

10 Things To Check In Your Google Analytics

This is part 2 of a multi-part series on increasing conversions from your website traffic.  If you haven’t already, you should read part one, which introduces the Infinite Conversion Loop.

The old cliché – “How do you know where you’re going, if you don’t know where you’ve been?” is especially applicable to Analytics.  Before you can even hope to get a handle on increasing the conversion rate of your website, you need to make sure you’re actually tracking all of the things that will help you analyze what’s going on!

Measuring Tape

The most common problem we encounter with customers here at LunaMetrics is an incorrect or incomplete Google Analytics configuration.  Here’s a checklist of a few of the things you should definitely be doing before going any further in the conversion loop.

  1. Is the tracking code on EVERY page (and is it functioning)? To get a complete picture of your website, you need to see how all content is performing, including legacy content, 404 pages, terms of service, you name it.  If it can potentially be viewed by a person, I’d recommend putting tracking code on the page.

  2. It’s also recommended you update to the Asynchronous code if you are not already using it.  In my experience it provides much more reliable numbers.   The second question of “is it functioning” can be tested by looking at your data in GA, and also using an HTTP monitor to make sure the utm.gif is being requested on page load.

  3. Are sub-domains and cross-domains being tracked correctly?  You need to be able to see how people are flowing from one domain to another to assure conversions are being attributed properly.
  4. Are goals configured, with funnels?  Specifically, are they configured correctly?  Being able to visualize funnels will be key for analysis.
  5. Is E-Commerce configured?  All E-Commerce sites should have E-Commerce configured (obviously) to track dollar values of transactions.  But really any site that can provide a concrete monetary value to an action should have this.  Does a confirmed lead generation add to your E-Commerce?  What about a donation?
  6. Is AdWords Linked?  If you do any type of AdWords spending, it’s crucial that you link your account to be able to see how well these campaigns are working.
  7. Are Campaign tags being used consistently and efficiently?  Are you even using Campaign tags in your marketing?
  8. Are you tracking Events? I recommend tracking any high value action as an event.  If people are leaving your site for a third-party site, that should be tracked as an event. Downloading a file, clicking a drop down menu, it’s up to you to decide what actions make the most sense as events.
  9. Is Site Search configured?  This is one of the most useful things you can do.  If you have a search box on your site, more likely then not a confused visitor will do a search to find what they are looking for.  If they still don’t find what they want from your search, you can guarantee this will add to your bounce rate.  (On the flip side, often a really useful search box can make up for other navigational problems your site may have).
  10. Are you tracking Social Engagement?  Today “The Net” is much more then the web.  If you don’t have a social component to your site, you should consider adding some type of social sharing widget right now.  Once you have that installed, it’s important to see how and where it’s being used to get a picture of your engagement. That’s where the GA Social Engagement plug-in comes in.
  11. Is AdSense linked?  If your business relies on AdSense as a revenue, you’ll definitely want to see how it performs on your site.

Now that you have all of this setup, next time we’ll talk about how to analyze this data (beyond page views and visitor counts!) to figure out what’s going on with your site and how you can begin to optimize. Ready to continue to part 3, find out who are These People Visiting My Website.

Google Analytics Custom Variables Not Working?

Custom variables... or not?

Everyone can agree: Google Analytics’ custom variables are a great feature. It lets you label your visitors with all sorts of fun stuff. Male or female? Member or non-member? Cat person or dog person? If you can identify your visitors’ answers to these sorts of questions, you can tag them with a custom variable.

But sometimes website owners implement the custom variable code and start gathering these valuable segments of traffic, completely unaware that the numbers aren’t very accurate. What could be causing such a heinous mistake?

Believe it or not, Google warns against the issue right in those instructions there, but they don’t call it out quite enough for my taste. It’s extremely important that you “call the _setCustomVar() function when it can be set prior to a pageview or event GIF request” (emphasis mine). Here are the details:

In certain cases this might not be possible, and you will need to set another _trackPageview() request after setting a custom variable. This is typically only necessary in those situations where the user triggers a session- or visit-level custom var, where it is not possible to bundle that method with a pageview, event, or ecommerce tracking call.

What exactly does this mean? Well, if a visitor fills out a survey on your site, hits submit, and you run _setCustomVar() after the _trackPageview() of the submission success page, that _setCustomVar() call just sits there in deep space, waiting for another _trackPageview() or _trackEvent() function to carry it along to Google’s servers. If that is the visitor’s final pageview in the session, then the call floats away forever, never to be heard from again.

The worst part, though, is if the visitor goes to another page, then the _setCustomVar() will tag along with any subsequent GIF requests. This means that it may appear as if the custom variable is working just fine, according to the reports in Google Analytics, but the numbers are just inaccurate.

So, to ensure that you are tracking your custom variables as precisely as possible, make sure that you always run the _setCustomVar() function before the calls to _trackPageview() or _trackEvent(). If this isn’t possible–you have an include at the top of every page, for instance, and can’t modify it–then be sure to include a second pageview or event after the _setCustomVar() function, like this:

_gaq.push(['_setCustomVar', 1, 'membership', 'gold', 1]);
_gaq.push(['_trackEvent', 'Tow Truck', 'go', '-', 0, true]);

This will ensure that every single time that function runs, it gets counted. Guaranteed!

Update: Tyson Kirksey, of Vertical Nerve, reminded me to set the event to non-interaction mode so that it won’t influence bounce rate, pages/visit, time on page, etc. I’ve also borrowed his clever naming convention for the event. Thanks, Tyson!