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.
Redirecting A User After They Comment
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.
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.
Keep On Growing 🙂