Chris Nanney

Logging Disqus Comments with Clicky

April 5, 2011
This post is over 13 years old

In the world of web development, this is ancient. What you see here may no longer be a good idea or in alignment with best practices. I've left the content mostly as-is, besides minor fixes for typos or dead links.

When someone makes a comment on my site, I like to see it in the visitor's action list on Clicky. If you're using Disqus with WordPress, here's an easy way to log comments.

Inside the Disqus plugin folder, open comments.php. Scroll down to the JavaScript, and look for:

1var disqus_config = function () {
2 var config = this; // Access to the config object

Inside this config function, paste this snippet:

1config.callbacks.onNewComment.push(function(){
2 clicky.log(window.location.pathname + '#post-comment', 'Post Comment');
3 clicky.goal('Post Comment');
4});

Here I've added "#post-comment" to the end of the current page URL. This is because Clicky only allows one title per URL, and the current URL is already matched with whatever the title of your page is. Since I want this action to show up with the title "Post Comment", I have to make the URL unique. For me, appending #post-comment makes it unique, but if you use that hash for something else on the page, change it. The point is to make it something unique for the purpose of logging comments.

I also log a dynamic goal named "Post Comment". Since I'm using Clicky Monitor, I get a nice desktop notification when someone leaves a comment.

This concept of adding a callback function for new comments can be applied however you use Disqus, it doesn't need to be with WordPress. This example is specific for Disqus & WordPress plugin. If you're including the Disqus JavaScript yourself without a plugin, the syntax is slightly different.