How to Track Account Creation Events in Google Tag Manager and Send Data to Google Ads and Analytics Answered

Post author
Nicolas Tizio

Hello everyone,
I'm looking for a way to go back to the account creation event in Google Tag Manager.

How can I upload this information to the datalayer?

I want to track the account creation event to send its data to Google Ads, and why not to Google Analytics.

Thanks 🙂

Comments

4 comments

  • Comment author
    Raquel Lopez

    Hello Nicolas,

    Let me give you some tips. But basically how you would handle it for Memberstack it would be for any other page. Using Google Tag Manager is standard for everything. Just keep in mind, I'm going to be talking about sending data to the dataLayer. How you want to connect it with difference services is another topic.So, for your specific user case that is account creation you can do it in a numerous ways.

    1. If you don't feel much comfortable with programming and your are using Memberstack data attributes to handle the account creation for you, then you can track clicks for the submit button of the account creation form. This method has its fails because it tracks clicks, not the actual response from the server. So it tracks more of an 'intent' than an actual account creation. You can do it and test it directly in the same Google Tag Manager interface.
    2. An accurate way of tracking it would be to handle the account creation using Memberstack frontend DOM package. It gives you much more flexibility but with the downsize you have to handle the form data yourself. You will have to wait for an success response from the server and then send the account creation event to the data layer.
      window.dataLayer = window.dataLayer || [];
      ...
      try {
      const signupResult = await memberstack.signupMemberEmailPassword(...);
      window.dataLayer.push({
       'event': 'account_creation',
       'userID': signupResult.data.member_id // sends additional data to the event
       });
      } 
      
      3. And last option you if you're really comfort with programming, you can build a server that listen to some Memberstack Webhooks (like account creation, account update, etc) and send the event via backend.So after you are tracking the event in the data layer, you can integrate with any service that you want that will trigger the corresponding event, like Google Analytics, Google Ads, Facebook Ads, and so on.

    0
  • Comment author
    Nicolas Tizio

    Hello Raquel Lopez,

    Thank you for your comprehensive reply!I finally found this solution:Add this script to the redirect page after creating the account:

    <!-- MS Event GTM Creation Account -->
    <script>
    // Immediately check if event was already tracked
    if (!sessionStorage.getItem('memberstack_signup_tracked') && 
        window.location.href.includes('/onboarding/about-you?welcome=newmember')) {
    
        // Mark as tracked immediately to prevent any double firing
        sessionStorage.setItem('memberstack_signup_tracked', 'true');
    
        // Push the event to dataLayer
        window.dataLayer = window.dataLayer || [];
        window.dataLayer.push({
            'event': 'memberstack_account_created'
        });
    }
    </script>
    

    And in GTM I add a trigger as soon as the ‘memberstack_account_created’ event is triggered in the DOM.

    0
  • Comment author
    Raquel Lopez

    Yes, that's a valid approach as well. You're redirecting your users to a page with query parameters, like a success page and fire an event from there. Like I said there are multiple ways of getting to the same solution. I think you don't even need to write code if you use the redirection method. And you can configure the tag to fire once per user (since the user is registered). But anyways. What you did, is enough🙂

    0
  • Comment author
    Nicolas Tizio

    Thanks Raquel Lopez, I'll try your solution.

    0

Please sign in to leave a comment.