Search code examples
google-analyticsgoogle-tag-manager

Track login event with google analytics 4


There's already a question similar to mine, but it doesn't tackle my problem.

I'm trying to set the google tag manager to track login events in my website. But I can't identify the action related to the login event on the tag assistant. Here is a print of the actions when I login:

enter image description here

None seem to be strictly related to the login event. I tried to track some of these actions, but they occur in many other actions. (thus, I collect data I don't need, as if they were login events)

What of these actions is related to the login event? How can I precisely identify the login action ?


Solution

  • You can automatically implement data layer events on form submissions with ListenLayer.com. In this case, you will likely need to use their Custom Forms Listener.

    You have to create an account, place their script on your website, enable the Custom Forms listener and it's features and then identify your forms under the Listener's event settings. You would do this by writing a simple rule to match the CSS class, ID, or form Name element etc. (these things would exist in the <form> tag.

    Here you can see I have set some rules to identify a form like this

    <form class="form-container"> or <form class="listenlayer">

    enter image description here

    Publish and test on your website.

    Now, when the form is submitted, the Listener will automatically push data into the data layer identifying the form and the action.

    From there you would use GTM to register and read the data layer activity. I assume you know how to do that since you have the GTM debug view going, but basically you'll get a new message on the left side with an event name and you can create a Custom Event trigger in GTM and also register Data Layer Variables to use in your trigger. It's all down hill from there!