• Follow us on Twitter
  • Join our Facebook Group
  • Join me on Google Plus
  • Add me on Linkedin
  • RSS

  • Home
  • Services
  • Tools & Downloads
    • Google Analytics Content Targeting Generator
    • A/B/n Split Test Confidence Calculator with Graphing
    • Simple Feedback Form with Google Analytics Integration
  • About
  • Contact

Blog - Latest News

Target Offers & Content at Visitors With Google Analytics

2 Comments/ in Analytics / by Robert Kingston
August 8, 2011

One of the lesser known features of Google Analytics is that you can use it to target offers and content through JavaScript – much like the features of BTBuckets and many split testing software providers. Unlike these providers however, using Google Analytics can be a cleaner, tidier way that has less of an impact on page load times (since it only needs the GA script to be loaded).

How it works

1. You set a custom variable at the visitor level scope (page and session level doesn’t work)
2. Using JavaScript, you read the contents of visitors’ custom variable slots
3. Based on the contents, you can show an offer or message to particular visitors

You can use it for targeting visitors of all sorts of segments – Customer Lifetime Value (high value, low value, none), User type (registered, paying customers, non-member), Facebook demographic data (if you’re using the Facebook Connect API) and many more. I’ll leave that up to you…

Test it out here.

The code that does it

It’s all based around the function, _getVisitorCustomVar() – have a read up on Google’s documentation about it here.

Simply place the slot number inside _getVisitorCustomVar() where your visitor level variable is set:

_gaq.push(function () {
	var segment = _gat._getTracker('UA-1XXXXXX-X');
	var bucket = segment._getVisitorCustomVar(1);
	if(typeof(bucket) == undefined) {bucket = '';}

	if (bucket == 'xyz') {
		// Do this...
	}
});

And if you’re using the old synchronous version (or perhaps you just NEED the content to be loaded synchronously):

var segment = _gat._getTracker('UA-1XXXXXX-X');
var bucket = segment._getVisitorCustomVar(1);
if(typeof(bucket) == undefined) {bucket = '';}

if (bucket == 'xyz') {
	// Do this...
}

To customise it further, please try my targeting generator script.

Notes:

  • Unless you’re going to re-use the tracking objects we created in the snippets above, you don’t need to update the UA number.
  • Since _gaq.push and _getVisitorCustomVar alone will simply return the position within the array, we needed to create a synchronous tracking object to extract it.
  • Only visitor level custom variables work – page and session levels just don’t work (_deleteCustomVar() is your friend).
  • For the synchronous version of the script, you MUST load ga.js synchrnously before the targeting script.

Recommended: Targeting Generator

Alternatively, you can use my free Google Analytics targeting generator to handle all of the customization for you.

Use the Google Analytics Targeting Generator

Why not use cookies and server-side scripting?

Sure! I just find this method integrates well with Google Analytics and your segments show up well within your reports. Also, you don’t need redundant scripts for reading/writing cookies.

← Download: Simple Feedback Form with Google Analytics Integration
Visualize Your Best Converting Hour & Day of the Week →
Comments

2 Responses to Target Offers & Content at Visitors With Google Analytics

  1. Alexander says:
    August 17, 2011 at 20:22

    Did you can provide some working example with this code? Code example and screenshot of GA report? Thank you.

    Reply
  2. Robert Kingston says:
    August 20, 2011 at 15:20

    Hi Alexander,

    You can find the working code and an example of it right here:

    http://www.crotricks.com/content-targeting-ga/example.html

    If you’d like to customize the code, there is a simple targeting generator script that I have built:

    http://www.optimisationbeacon.com/tools-tweaks/google-analytics-content-targeting-generator/

    Try it out and let me know if you have any troubles.

    Reply

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

About Rob

I'm an ex-Hitwise Analyst turned freelancer that helps clients turn their analytics data into better converting websites. I also like to run, drink, eat and be merry. My girlfriend, on the other hand, would say I play too many computer games and use my Androids too much (yeah, right :P).

Subscribe For More Great Tips


Subscribe by RSS


Follow me on Twitter


Follow Optimisation Beacon on Google+

Categories

  • Analytics
  • Conversion Rate Optimisation
  • Marketing & Consumer Insight
  • News
  • Testing

Most Popular Posts

  • Google Analytics’ New Site Speed Report Tracks Page Load Times
  • Track WordPress Blog Comments in Google Analytics
  • Build a Conversion Rate Heatmap by Hour & Day of Week in Google Docs
  • Track Page Load Times with Google Analytics’ Asynchronous Script
  • See Google Website Optimizer (MVT) Tests in Google Analytics

Recent Posts

  • Web Browsers Most Susceptible to Browser Fingerprinting
  • Cohorts.js: Open Source JavaScript MVT Split Testing Framework
  • 10 Sources of Direct Traffic & How To Track Direct Shares
  • Track What Visitors Copy From Your Site in Google Analytics
  • Track How Far Your Users Scroll in Google Analytics

Blogroll

  • Analytics Ninja
  • Justin Koro
  • LunaMetrics Blog
  • Marketing Experiments
  • SnowPlow Analytics
  • Teacup Marketing
  • Visitor Centric CRO Community
  • Home
  • Services
  • Tools & Downloads
    • Google Analytics Content Targeting Generator
    • A/B/n Split Test Confidence Calculator with Graphing
    • Simple Feedback Form with Google Analytics Integration
  • About
  • Contact
417Follower294Subscribers
© Copyright - Optimisation Beacon - Wordpress Theme by Kriesi.at