• Resolved shaniz

    (@shaniz)


    Hi,

    I need to track GA event when the registration is successful. Can I know a listener event or any other option to track the successful registrations?

Viewing 11 replies - 1 through 11 (of 11 total)
  • Plugin Support Aswin Giri

    (@aswingiri)

    @shaniz You can user this hook to run a function after registration is complete. Please check the sample code and change it accordingly.

    add_action( ‘um_registration_complete’,function($user_id, $args){
    // your code goes here, $user_id is the id of the newly added user.
    },10,2);

    Hope this works for you.

    Thread Starter shaniz

    (@shaniz)

    @aswingiri So is it possible to add a javascript with scripts tag inside this hook?

    Plugin Support Aswin Giri

    (@aswingiri)

    You can always add javascript with hook

    add_action(‘wp_footer’,function(){

    });

    Thread Starter shaniz

    (@shaniz)

    @aswingiri But I need to track the successful registrations and trigger a event to google analytics. So I cannot user the wp_footer to add my javascript. Isn’t this possible?

    Plugin Support Aswin Giri

    (@aswingiri)

    You can write javascript with in action callback.

    Thread Starter shaniz

    (@shaniz)

    @aswingiri So it means that I need to edit the plugin core?

    Plugin Support Aswin Giri

    (@aswingiri)

    @shaniz No, you dont need to edit plugin core. You just have to hook it to action hook. Like in the example below:

    add_action( ‘um_registration_complete’,function($user_id, $args){
    ?>
    <script>
    alert(‘Hello’);
    </script>
    <?php
    },10,2);

    But remember this script will be included on page when this action triggers.

    Thread Starter shaniz

    (@shaniz)

    @aswingiri This alert is not working once I added this. But when I added some php codes inside the action then it is working

    Plugin Support Aswin Giri

    (@aswingiri)

    I think you should just add js to wp_footer action

    Thread Starter shaniz

    (@shaniz)

    @aswingiri Yes I can run the script in the wp_footer action but it is not possible to track the successful registration if I do not run it within the um_registration_complete action.

    Below is the code I need to run.
    ga(‘send’, {
    hitType: ‘event’,
    eventCategory: ‘Register Form’,
    eventAction: ‘register’,
    eventLabel: ‘register’
    });

    Plugin Contributor Champ Camba

    (@champsupertramp)

    Hi @shaniz

    Sorry for the late response. Could you please tell us if you’re still having issues?

    Please feel free to re-open this thread if there’s any question that may come up.

    Regards,

Viewing 11 replies - 1 through 11 (of 11 total)

The topic ‘Tracking Registration Event’ is closed to new replies.