1

Title says it all really:

How do you set up a StackExchange site for use with Google AdWords and Analyitics?

flag

1 Answer

2

Assuming you already created a Google Analytics and Google AdWords account, the first step is to link them altogether. Check out the following answers for more details:

Then you need to install Google Analytics on you StackExchange site. This is really straightforward. Enter the administration area and go to Admin > Content > Footer. Paste here your Google Analytics tracking code as shown in your Google Analytics Account.

Next step is to configure some Goals and tracking scripts in order to collect useful information from your StackExchange users. I can't tell you what you need to do because it depends on what you want to track as Google Analytics goal.

For Search Marketing Arena, for example, we decided to keep track of the most significan actions including user registration, comments, answers and votes. Here's the final script, derived from this answer (credits goes to interneter).

<script src="/js/jquery.url.packed.js"></script> 
<script type="text/javascript"> 
//<![CDATA[

// Firebug is enabled
var hasFirebug = (window.console && window.console.firebug);

var trackDebug = function(message) {
  if (hasFirebug) {
    console.debug(message);
  }
};

$(document).ready(function(){
  var pageurl = jQuery.url.attr("path");

  $(".vote-up").live("click", function() {
    pageTracker._trackEvent('question', 'vote up', pageurl, 1);
  });
  $(".vote-down").live("click", function() {
    pageTracker._trackEvent('question', 'vote down', pageurl, 1);
  });
  $(".vote-favorite").live("click", function() {
    pageTracker._trackEvent('question', 'fav', pageurl, 1);
  });
  $(".comment-up").live("click", function() {
    pageTracker._trackEvent('comment', 'vote up', pageurl, 1);
  });
  $("form[class='post-comments']").submit(function() {
    pageTracker._trackEvent('comment', 'add new', pageurl, 1);
  });
  $("form[class='post-form']").submit(function() {
    pageTracker._trackEvent('question', 'add new', pageurl, 1);
  });
  $("input[value='Create New User']").click(function() {
    pageTracker._trackEvent('account', 'add new', pageurl, 1);
  });
});
//]]>

</script>

Plese note that /js/jquery.url.packed.js is a jQuery plugin and it's not part of a default StackExchange installation. You need to create a new StackExchange static page and copy/paste the code from here.

Now you can easily monitor your performances playing around with Google Analytics reports. But you still don't have any Goal defined. This is because the code above use Google Analytics Events and, right now, Google Analytics can't use an event as Goal. If you want to create a goal, for example, each time a user sign up, then you need to create a virtual URL with trackPageview() and configure the URL as goal.

Back to the original example, change the following lines

  $("input[value='Create New User']").click(function() {
    pageTracker._trackEvent('account', 'add new', pageurl, 1);
  });

to

  $("input[value='Create New User']").click(function() {
    pageTracker._trackEvent('account', 'add new', pageurl, 1);
    pageTracker._trackPageview('/events/accounts/new');
  });

Go to your Google Analytics account and create a new Goal. Select Match Type Head Match and use /events/accounts/new as Goal URL. That's all! Now you can start your first Google AdWords campaign and track your campaign conversions in Google Analytics.

link|flag

Your Answer

Get an OpenID
or

Not the answer you're looking for? Browse other questions tagged or ask your own question.