I recently implemented Disqus comments on my blog and have used them in the past. They’re great for allowing users to post a comment with their social media account. It’s also really easy to implement on any website.

In this post, we’ll take a look at how you can track comments in Google Analytics using Google Tag Manager.

1. Paste the Disqus universal code on your website

I won’t go into detail here on how to perform this step as Disqus provides plenty of documentation on this. Just be sure that you fill in the PAGE_URL and PAGE_IDENTIFIER. More info on the importance of this can be found here. Trust me. You’ll want to make sure you do it because you can run into some hairy situations in the long run if you don’t.

2. Add an event to the onNewComment callback

Within the disqus_config function, we will add the onNewComment callback function to listen for successful comment submissions. Within the onNewCallback function, we’ll push an event to GTM that will allow us to trigger a comment submission tag in GTM. Your code should look like this:

3. Add a custom event trigger

Create a new custom event trigger and set the event to comment_submit. This trigger will now fire whenever comment_submit event is pushed to GTM through the onNewComment callback function.

Screen Shot 2015-10-28 at 11.00.33 PM

4. Create an event tag

Create a new GA event tag and set the values as shown below. Note that I set the event label to another custom variable illustrated from one of my other posts. You can easily pass in the URL or something uniquely identifiable in there. Since you can already get the URL from a second dimension, I’m using my post title instead. Set the trigger we created in step 3.

Screen Shot 2015-10-28 at 11.06.11 PM

5. Test

Submit a comment and see it in action.

Screen Shot 2015-10-28 at 11.12.03 PM