About "Create New Account" button and tracking Sign Ups

It might be possible to hook into the user_created event and use that to send data to an analytics platform. If that was the case, it would be possible to do something like this. :warning: Note that this code doesn’t work:

<script type="text/discourse-plugin" version="0.11.0">
api.onAppEvent("user:created", user => {
    if (user) {
        window.dataLayer.push({
        'event': 'userCreated'
        });
    }
});
</script>

The above code is following the pattern outlined here: Setup Google Tag Manager for Analytics.

As far as I can tell, the user_created event is not available on the client, so the above code will not work. If anyone knows if it’s possible to catch the user_created event on the client, please let me know.

2 Likes