How to track users log-in

Hello,

After a lot of research I haven’t found any answers to my question about my problem.

I have activated the “membership” feature on my site, but I would like to track the connections made to my site.

I would like to have data to exploit each time a user connects via the log-in page.

The data to extract would be quite simple: the email address and the date and time of the connection of this user.

The purpose of this is to know who connected to my site during a given event and to be able to give an analytical feedback to my client.

I tried several times to install an event tag manager => GA4 but after many failures I could not extract any information other than: a connection took place (without knowing which user connected).

Is there a way to have this information extracted in a document?

Currently I have managed to configure a webhook but it is only activated when I update a user manually from the list of member accounts. I have to update each member myself for it to be activated.

Sorry if my request is not clear but I am a novice in this field and want to learn more!

Thanks in advance for your help.

You will need custom code, basically you will need to intercept the login form call, (create a fake submit button), save the email data and date and store in local storage, then with js you trigger the real submit button on page load of your redirected page, you check data inside localStorage, send the event to ga4, webhook, whatever you want and clean up localStorage

The Sygnal Attributes logged-in user info lib does the user-data assembly part.
There is a callback to tell you when the user data is available, and you could use that.

Note there is not a callback specific to a login event, which is an interesting use case. If you’d like to add that to the wishlist, you can do that here.

Hey, I found how to deal with it, chat GPT 4 had my back. I tought it would be interesting to share it with you !

Here is a tutorial :

Creating the “Timestamp” variable in GTM:
a. Go to the “Variables” tab in the left sidebar of GTM.
b. Click on “New” to create a new variable.
c. Name the variable “Timestamp”.
d. Select the variable type “Custom JavaScript”.
e. Copy and paste the following code into the “Custom JavaScript Code” field:

function() {
return new Date().toISOString();
}

f. Save.

Creating the “Email Value” variable in GTM:
a. Go to the “Variables” tab in the left sidebar of GTM.
b. Click on “New” to create a new variable.
c. Name the variable “Email Value”.
d. Select the variable type “Custom JavaScript”.
e. Copy and paste the following code into the “Custom JavaScript Code” field:

function() {
var emailInput = document.querySelector(‘#wf-log-in-email’);
if (emailInput) {
return emailInput.value;
}
return undefined;
}

f. Click on “Save”.

Creating the “GA4 Configuration” tag:
a. Click on “Tags” in the left sidebar of GTM.
b. Click on “New” to create a new tag.
c. Name the tag “GA4 Configuration”.
d. Select the tag type “Google Analytics: GA4 Configuration”.
e. Configure the tag settings:
Measurement ID: (Enter the corresponding GA4 measurement ID, for example, “G-XXXXXXXXXX”).
f. In the “Triggering” section, add the trigger “All Pages” or a custom trigger that fits your needs.
g. Click on “Save”.

Creating the “GA4 Login Form Submission” tag:
a. Click on “Tags” in the left sidebar of GTM.
b. Click on “New” to create a new tag.
c. Name the tag “GA4 Login Form Submission”.
d. Select the tag type “Google Analytics: GA4 Event”.
e. Configure the tag settings:
Measurement ID: (Enter the corresponding GA4 measurement ID, for example, “G-XXXXXXXXXX”).
Event Name: “login_gpt”
Event Parameters: name: “email”, value: “{{Email Value}}”, name: “login_timestamp”, value: “{{Timestamp}}”.
f. Click on “Save”.

Creating the “Login Form Submission” trigger:
a. Click on “Triggers” in the left sidebar.
b. Click on “New” to create a new trigger.
c. Name the trigger “Login Form Submission”.
d. Select “Form Submission” as the trigger type.
e. Check “Some Form Submissions”.
f. Configure the following condition:
Click Element matches CSS Selector “form[data-wf-user-form-type=‘login’]”.
g. Click on “Save”.

Be aware that will “track” login attempts, not logins. The way you’ve designed it would try to track any random email submission regardless of whether it’s a valid user or whether they know the correct password.