Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Google Tag Manager - Track All Registrations with Google Analytics

mtschirsmtschirs ✭✭✭
edited August 2015 in Vanilla 2.0 - 2.8

I am using the Google Tag Manager (check out my newest Tag Manager Plugin :winky:) to track guests and users on my site.

Now, I want to track registrations of new users. This works fine for local registrations:

  1. In Tag Manager, create a new trigger that fires when a submitted Form ID equals "Form_User_Register".
  2. In Tag Manager, create a new Universal Analytics tag that fires on this trigger and creates a new 'Registration' event.

However, I also want to track social sign-ups via e.g. Facebook Connect or OpenID.
The problem is, the connect form does not have an ID and the URLs are different for each connect plugin. Is there a unified landing page after successful registration? How do you track social sign-ups?


  • Options

    Every user account is registrated through UserModel::register, so you can use the UserModel_AfterRegisterevent to cover all cases.

  • Options
    mtschirsmtschirs ✭✭✭
    edited August 2015

    hm, I could redirect to a special landing page via this event + plugin and then track visits to that landing page. But I will wait for other, possibly cleaner suggestions first.

  • Options
    BleistivtBleistivt Moderator
    edited August 2015

    This is probably the cleanest suggestion. It covers all registrations.

    If you need to redirect to a page, I would stash a parameter in the users session on the AfterRegister event:

    Gdn::session()->stash('NewRegistration', true);

    Then you can redirect based on that:

    if (Gdn::session()->stash('NewRegistration')) {

    You could also use the value in the session stash to insert the tracking code.

    But there might not be a session at this point (I haven't tested), in that case you could use the user attributes for this.

  • Options
    R_JR_J Ex-Fanboy Munich Admin

    @Bleistivt said:
    Gdn::session()->stash('NewRegistration', true);

    if (Gdn::session()->stash('NewRegistration')) {

    Whoa, that's what I would have often needed for some quick and dirty debugging!

  • Options
    mtschirsmtschirs ✭✭✭

    @Bleistivt: It might be clean if one performs server-side tracking, but Google Tag Manager injects external javascript and should ideally not require additional server side logic.

    A cleaner solution would e.g. be if all social registration forms had an ID such as "Form_User_Register_Facebook". This would allow very precise tracking per social plugin out of the box.

  • Options
    AdrianAdrian Wandering Spirit Montreal MVP


    this is one way you can track signin by type

    /*Social Sign-in */
    $('a.SocialIcon.SocialIcon-Google,a.SocialIcon.SocialIcon-Google.HasText').one('click', function() { ga('send', 'event', 'button', 'click', 'sso-google');});
    $('a.SocialIcon.SocialIcon-OpenID,a.SocialIcon.SocialIcon-OpenID.HasText').one('click', function() { ga('send', 'event', 'button', 'click', 'sso-openid');});
    $('a.SocialIcon.SocialIcon-Twitter,a.SocialIcon.SocialIcon-Twitter.HasText').one('click', function() {ga('send', 'event', 'button', 'click', 'sso-twitter');});
    $('a.SocialIcon.SocialIcon-Facebook,a.SocialIcon.SocialIcon-Facebook.HasText').one('click', function() {ga('send', 'event', 'button', 'click', 'sso-facebook');});
    /*Standard Sign-in */
    $('input#Form_SignIn.Button.Primary').one('click', function() {ga('send', 'event', 'button', 'click', 'standard-signin');});

    You'll also need to add this to conf/config.php to ensure it works well:

    $Configuration['Garden']['SignIn']['Popup'] = FALSE;

  • Options
    mtschirsmtschirs ✭✭✭

    Thanks for sharing, @Adrian! I might translate this into a GTM trigger for signin tracking.

Sign In or Register to comment.