• View our reviews on Hot Scripts
  • JS Tutorial

Recent Comments

Powered by Disqus

Back to articles

Collect feedback using Google Analytic

Feedback Easy class can provide website visitors with option to rate website and/or leave small comment.

Ratings and comments are saved as google analytic events and can be viewed in according section of Google Analytics. Events are updated once in 24 hours.

This object also sets custom variable, which marks visitor and prohibits from rating and leaving comment again.

Package contains feedback_easy.js and feedback_easy.packed.js (packed javascript) and one example file: example.html, which displays rating form.



Example codes

<style type='text/css'>
    text-align: center;
    width: 250px;
#feedback > div
    margin-top: 5px;
    margin-bottom: 5px;
    margin-left: auto;
    margin-right: auto;
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-XXXXXXX-XX']);

  (function() {
    var ga = document.createElement('script'); 
    ga.type = 'text/javascript'; ga.async = true;
    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www')
    + '';
    var s = document.getElementsByTagName('script')[0]; 
    s.parentNode.insertBefore(ga, s);
<div id='feedback'></div>
<script type="text/javascript" src="./feedback_easy.packed.js" ></script>
<script type="text/javascript">
var f = new feedback_easy("feedback",{
    //maximal rating unit
    max: 10,
    //allow to leave comment
    comment: true,
    //allow to close form without feedback
    allow_close: true,
    //graphic for empty rating unit
    graphic_empty : "./star_empty.png",
    //graphic for full rating unit
    graphic_full : "./star_full.png",
    //encouraging text
    rate_text : "Rate this website:",
    //thank you text
    thanks_text: "Thank you for feedback",
    //text for submit button
    submit_text: "Submit",
    //text for close link
    close_text: "x",
    //callback function for submitted form
    callback : null,
    //callback function for closed form
    onclose : function(){
        document.getElementById("feedback").style.display = "none"
    //do not allow to submit empty comment input
    force_comment: false

Examples in action

Example scripts provided with package in action:

Method list


Back to method list

Method namenew feedback_easy(id, config)
DescriptionCreate Feedback Easy instance with provided configuration
Input parameters

string id - id of html element where to create feedback form

json config - configuration options:

  • int max - maximal rating, from 1 to max (default: 5)
  • bool comment - allow to leave small comment (default: true)
  • bool graphic_empty - path to graphic file for empty rating unit (default: "./star_empty.png")
  • bool graphic_full - path to graphic file for full rating unit (default: "./star_full.png")
  • string rate_text - text or html to encourage visitors to leave feedback(default: "Rate this website:")
  • string thanks_text - thank you text or html to visitor for provided feedback(default: "Thank you for feedback")
  • string submit_text - text value for submit button (default: "Submit")
  • string close_text - text or html for closing link (default: "x")
  • function callback - which function to call, when user submits feedback (default: null)
  • function onclose - which function to call, when user closes feedback form (default: hides form)
  • bool force_comment - do not allow to submit empty comment input area (default: false)

Latest changes

None for now

Rate us

Like our script? Rate it at JavaScript > Hot Scripts

Try it out and Rate on


JS classes support forum or comments below

You may also be interested in:

Powered by

blog comments powered by Disqus