How to catch click events within topic posting form with javascript?


I’m trying to integrate discourse into our existing gamification system for our main site. (We’re using captainup which is based on an event-driven point system)

I can catch the New Topic click just fine, but can’t catch any of the click events within the topic form popup (the main one I want being the Create Topic button)

I know this is due to ember, which I’m new to - any tips?

Google Analytics Event Tracking
How to catch click events on a link in order to fire a pixel
(Simon Cossar) #2

Clicking the ‘Create Topic’ or the ‘Reply’ button from within the composer calls the ‘save’ action in the composer controller. You could override the save action with something like this as custom javascript:

<script type="text/discourse-plugin" version="0.8.23">
api.modifyClass('controller:composer', {
    actions: {
        save() {
            console.log('The post has been saved!', 'New topic?', this.get('model.creatingTopic'));

How to catch click events on a link in order to fire a pixel

That worked! Thank you @simon_cossar.

(Alon Levi) #5

Hi @Simon_Cossar, any option to use this kind of code to capture clicks on links/or buttons?
I need to fire a pixel to Google Adwords when a user clicks a link.
Thanks :slight_smile:

( #9

Do you happen to know what the snippet would be for tracking likes (:heart:) on posts?