Disqus Comments Growth Hack

This tip allows you to redirect a user after they leave a disqus comment on a specific blog post.

If you use Disqus on your blog there’s a few nice things you can do to drive more community discussion. The one I’ll be focusing on in this guide is how you reward the user once they’ve left a comment.

Disqus has a callback that triggers when a user leaves a comment.

This essentially allows you to do anything you like after a comment. This includes things like:

  • Redirecting the user somewhere else
  • Triggers an opt-in form
  • Tracking the comment in Analytics

In this guide we’re going to look at how to redirect the user somewhere after they comment. Specifically inside WordPress.

One of the best ways to drive discussion is to give users an incentive. In fact, I gave you an incentive to comment on a blog post to come here. It worked right? This redirect trick allows you to send the user to the desired incentive location after their comment.

Just a note: You absolutely should make users aware that you are doing this.

To redirect the user we need to do two things. First we need to include the callback script, then we need to use window.location.href to send them to the desired URL.

<?php $commentredirect = get_post_meta($post->ID, 'redirect', true); if ($commentredirect) { ?> <script type="text/javascript">function disqus_config() { this.callbacks.onNewComment = [function() { window.location.href = "<?php echo get_post_meta( get_the_ID(), 'redirect', true ) ?>" }]; }</script> <?php } ?>

This should be included just before the Disqus comments script inside your Theme. We’ll be using a custom field inside the post to trigger the redirect. The script above also looks to see if the custom field exists first before executing the script.

Once that’s all setup we just need to add a custom field to our post with the redirect URL. In the case above our custom field is named redirect.

Disqus Comment Custom Fields

Enjoy!

Keep On Growing 🙂

Author

Stuart McKeown

Stuart McKeown is one of the Co-founders at Gleam. Aside from writing and helping businesses grow, he also enjoys sound design and drinking tea ☕️