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 which already exists within the universal embed code:
var disqus_config = function () {
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, 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 and comment text for further analysis the following way:
var disqus_config = function () {
this.callbacks.onNewComment = [function(comment) {
alert(comment.id);
alert(comment.text);
}];
}
Example within Full Embed Code
/**
* RECOMMENDED CONFIGURATION VARIABLES: EDIT AND UNCOMMENT THE SECTION BELOW TO INSERT DYNAMIC VALUES FROM YOUR PLATFORM OR CMS.
* LEARN WHY DEFINING THESE VARIABLES IS IMPORTANT: https://disqus.com/admin/universalcode/#configuration-variables
*/
var disqus_config = function () {
this.page.url = PAGE_URL; // Replace PAGE_URL with your page's canonical URL variable
this.page.identifier = PAGE_IDENTIFIER; // Replace PAGE_IDENTIFIER with your page's unique identifier variable
this.callbacks.onNewComment = [function(comment) {
alert(comment.id);
alert(comment.text);
}];
};
(function() { // DON'T EDIT BELOW THIS LINE
var d = document, s = d.createElement('script');
s.src = '//EXAMPLE.disqus.com/embed.js';
s.setAttribute('data-timestamp', +new Date());
(d.head || d.body).appendChild(s);
})();
Please enable JavaScript to view the comments powered by Disqus.