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

 

3 Replies

  • 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.

     

  • Mattpx's avatar
    Mattpx
    Guide
    8 years ago

    Hello VarunGrazitti

     

    Thank you for the answer. The community uses the Lithium login, I first tried what you suggested with the url but I couldn't find anything in the admin to edit/add an success url/page, that's why I ended up adding the JS code on the registration page itself. Unfortunately there is no parameter in the url that I can use to "detect" a success:

     

    Registration URL(s): https://community.mydomain.com/t5/user/userregistrationpage?dest_url=https%3A%2F%2Fcommunity.mydomain.com%2F or https://community.mydomain.com/t5/user/userregistrationpage

     

    After registration: https://community.mydomain.com/

     

    Is there something I can do with FreeMarker?

     

    <#if "user first login" >
    // Tracking code here
    </#if>

     

    Thank you,

    Matt