Forum Discussion

Mattpx's avatar
Mattpx
Guide
8 years ago

Google event tracking on user registration

Hello,

 

I am trying to fire an event on user registration, I currently have the following code which is not optimal since it is triggered even if the registration fails. Is there a success page or a javascript callback I can use when the registration is successful?

 

$('.lia-component-user-registration-form').submit(function() {

    ga('send', {
        hitType         : 'event',
        eventCategory   : 'Registration',
        eventAction     : 'submit'
    });
});

Thank you!

Matt

 

  • Mattpx - You can add this script on the success page itself. Does your community use the SSO or Lithium login? If it is lithium login, you can check the URL to see if the registration is successful or not. If SSO, you must be redirecting the users back to the community, hence you can check the params from URL and add your tracking code inside a condition. The implementation will be same in both the cases basically.

    e.g.

    <#if http.request.url?contains("Success")>
    //Your code goes here
    </#if>

    I hope this helps.