Build Your Own Feedback Form in Google Analytics
Update August 2011: Have made available publicly, the code for my simple feedback form with Google Analytics integration.
Update November 2010: Made a note about tracking visitor comments in Analytics and how I’m testing it.
Update: Removed “Maybe” response with 0.5 score as Analytics only supports passing integers.
Sometimes your goal is not to optimise for revenue, but for the ability of your website to solve people’s problems. The issue is, there’s no website metric which tells you how much a page fulfills this goal. There’s no “Solve Rate” for your content in Google Analytics.
That is why I built a feedback tool into Google Analytics (OK, OK, I’m no web designer):
It looks simple and it is. I designed it based on Google’s own feedback mechanism for its support sites:
How it works
Visitors arrive on a page and a little overlay pops up in the corner of the screen (if you’re reading this via RSS, visit my site to see it in action). Each time a visitor answers a question, the feedback is sent through to Google Analytics as an event. You should then get to see great stats in Google Analytics like:
Installation
It couldn’t be easier to install. Just follow these steps:
- Ensure you have a Jquery library refrenced in your site’s header
- Paste some CSS code in your header
- Paste some Jquery and HTML code before your closing body tag
Header code
Place this code before your closing head tags.
<style> .gaFeedbackDiv { display:none; position:fixed; bottom:10px; right:10px; padding: 5px; background-color:#b4edfe; border-style:dashed; border-width:3px; border-colour:blue; } </style>
Footer code
Place this code before your closing body tags.
<script type="text/javascript"> $(document).ready(function(){ $('#gaFeedbackEnough').hide(); $('#gaFeedbackRecommend').hide(); $('#gaFeedback').show('slow'); var gaLP = document.location.pathname; var gaFL = 0; var gaFE = 0; var gaFR = 0; $('#gaFeedbackLike').children('input').click(function() { var gaFeedbackLike = $('input:radio[name=gaFeedbackLike]:checked').val(); if (gaFeedbackLike = "Yes") { var gaFL = 1;} _gaq.push(['_trackEvent','Did You like it?',gaFeedbackLike,gaLP,gaFL]); $('#gaFeedbackEnough').show('fast'); $('#gaFeedbackRecommend').show('fast'); $('#gaFeedbackLike').html(''); }) $('#gaFeedbackEnough').children('input').click(function() { var gaFeedbackEnough = $('input:radio[name=gaFeedbackEnough]:checked').val(); if (gaFeedbackEnough = "Yes") { var gaFE = 1;} _gaq.push(['_trackEvent','Enough details?',gaFeedbackEnough,gaLP,gaFE]); $('#gaFeedbackEnough').html(''); }) $('#gaFeedbackRecommend').children('input').click(function() { var gaFeedbackRecommend = $('input:radio[name=gaFeedbackRecommend]:checked').val(); if (gaFeedbackRecommend = "Yes") { var gaFR = 1;} _gaq.push(['_trackEvent','Recommend to friends?',gaFeedbackRecommend,gaLP,gaFR]); $('#gaFeedback').html('<strong><p>Thanks!</p></strong>'); $('#gaFeedback').delay(800).fadeOut('slow'); }) }) </script> <div id="gaFeedback" class="gaFeedbackDiv"> <div id="gaFeedbackLike"><strong>Did you like this page?</strong> Yes <input type="radio" name="gaFeedbackLike" value="Yes"> No <input type="radio" name="gaFeedbackLike" value="No"> </div> <div id="gaFeedbackEnough"><strong>Were there enough details?</strong> Yes <input type="radio" name="gaFeedbackEnough" value="Yes"> No <input type="radio" name="gaFeedbackEnough" value="No"> </div> <div id="gaFeedbackRecommend"><strong>Would you recommend this?</strong> Yes <input type="radio" name="gaFeedbackRecommend" value="Yes"> No <input type="radio" name="gaFeedbackRecommend" value="No"> </div> </div>
Save and upload that to your site and you’ll now be asking visitors three simple questions:
-Did you like this page?
-Were there enough details?
-Would you recommend this?
Why this set of questions?
Rather than use Google’s questions (tailored to ensuring content answers people’s questions) I tailored it to suit my own objectives.
1. Establish a loyal readership with quality Analytics and optimisation articles
2. Get exposure in the broader community
I feel the answers to the questions I chose will help me measure and track my progress relative to my objectives. Simply put, it’s important to consider YOUR objectives and write questions which helps you specifically. With that in mind…
How to choose your own questions
Let me know in the comments if you’re interested. I’ll update the post to cover modifying the code to reflect your own questions.
Can we use Google Analytics to collect COMMENTS from visitors?
In short, yes (I tested it and it works tremendously). Whether it’s legal is the key issue though.
The problem with collecting comments analytics is that people could leave personally identifiable information. And given how much data you already have on visitors in GA, that creates some problems.
One workaround that I’m testing: I post my visitors’ comments to a CSV file on my site through AJAX. So far I have had great results, but I haven’t tested it yet fully. Once I’ve tested this, I’ll let you know.
I love the form your using at the moment. Unlike the one you describe in your post, it is very useful for websites with less content on the pages. If you need another guineapig, let me know!
Thanks Martijn, I’m glad you like it. It’s kind of buggy still and missing features like being able to connect to a database, but the feedback is really useful. I’ll make some tweaks to it and email you the code to install on your site this afternoon.
Hi there,
I saw your example and customised it a fair bit to work with current GA.
I only got it complete today, so it hasn’t been optimised, but it now works off a href click to initiate the function to show it, plus some jquery to give it a nice animation, and a few yes/no questions, as opposed to one. Also works with new GA. Would you like me to send this to you?