Capturing Disqus commenting activity via callbacks

If you would like to track new comments and replies via your own analytics service, such as Omniture or Google Analytics, you can do so via the following callback function.

The following callback can be added to the disqus_config function before the main Disqus Javascript include:

function disqus_config() {
    this.callbacks.onNewComment = [function() { trackComment(); }];
}

Make sure to replace trackComment(); with the script you wish to track via your analytics service.

NOTE: If you're using the Wordpress plugin, this variable is already set. To avoid overriding it, you'll need to edit the plugin and add your tracker to the existing disqus_config function.

Getting comment information

This callback function accepts one parameter comment which is a JavaScript object with comment ID and text. For example you can find the unique comment ID for further analysis the following way:

function disqus_config() {
    this.callbacks.onNewComment = [function(comment) { 
      alert(comment.id);
    }];
}
Ask the Community Contact us

Still need help? Discuss Disqus is our most active place for getting quick help, sharing feedback, and discussing issues with others – a knowledgeable and helpful support team and community are there right now. Our 101 post is the best place to get started.

Make sure to search our Knowledge Base first... your answer might be just a click away!