[UPDATE - January, 19th 2012] I update the code so it is compatible with all question type.
[UPDATE - January, 25th 2012] I fix two bug. 1) Now the GA event is fire. 2) surveyId extraction is cleaner.
[UPDATE - February, 23th 2012] Added some screenshot from Google Analytics
For a while, I searched a way to track KISSInsights with Google Analytics (GA). I wished to use the GA _trackEvent tag to capture the actual question/answer.
Here the code (using jQuery):
// This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.
// Fire when the user submit the survey.
_kiq.push(['eventHandler', 'submit', function(){
// Retrieve KISSIsights survey ID.
surveyId = $("[src*='kissinsights.com']").attr("src").match(new RegExp("(id=)([0-9]*)&"))[2];
// For each survey questions...
for (i = 0; i < $("[class*='ki_question']").length; i++) {
// ... get the question text...
question = $("[class*='ki_h1']:eq("+i+")").text();
// ... and the selected anwser text
// Check first for radio button answer.
anwser = $("[class*='ki_question']:eq("+i+") input:checked[type='radio']").closest("label").text();
// Then for checkbox answer
if (anwser == "" || anwser == null || anwser == undefined) {
anwser = $("[class*='ki_question']:eq("+i+") input:checked[type='checkbox']").closest("label").text();
}
// Then for textbox answer(s)
if (anwser == "" || anwser == null || anwser == undefined) {
anwser = $("[class*='ki_question']:eq("+i+") textarea").val();
}
// And finaly, score
if (anwser == "" || anwser == null || anwser == undefined) {
anwser = $("[class*='ki_question']:eq("+i+") [class*='active'] a").text();
}
// If both data are available, queue a Google Analytics _trackEvent tag.
if (question && anwser) _gaq.push(['_trackEvent', 'VOC', surveyId, question +' | ' + anwser]);
}
}]);
Basically, this code is trigger when a user submit his answer. It will create a _trackEvent tag for each question/answer(s) pair. The beauty of the code is that it fetch the actual text value automatically and save it in a readable way into GA.
- Event category: Always VOC (you can change it to any thing you like.)
- Event action: The actual survey id (so if you have multiple survey running at the same time, each one would be save separately in GA.)
- Event label: "Question text | Answer(s) text"
Doing so, I could then create segments and custom reports in Google Analytcs base on that Voice of Customer (VoC) data.
For example:
- Which traffic source yield better satisfaction?
- Does satisfaction impact goal completion rate?
- Does satisfaction impact frequency/recency of visitor?
Here a example on how to create a custom report in Google Analytics to categorize outcome base on survey answer.
And here a example directly from the Google Analytics Events report.
Enjoy and feel free to let me know/share if you like :-)
[UPDATE - January, 20th 2012] You could easily modify the tracking to use an alternate version. Your choice.
if (question && anwser) _gaq.push(['_trackEvent', 'VOC-' + surveyId, question, anwser]);
- Event category: VOC-surveyID (so if you have multiple survey running at the same time, each one would be save separately in GA.)
- Event action: Question text
- Event label: Answer(s) text


















