Skip to main content
All CollectionsLeadfeederTracking Script
How to Track Logged-in Users on Your Site
How to Track Logged-in Users on Your Site

With the Leadfeeder Identify Call you can track individuals that log in on your site with their email address.

Helena Hrubesova avatar
Written by Helena Hrubesova
Updated over a year ago

What is the Leadfeeder Identify Call?

Leadfeeder Identify Call is one of the methods that Leadfeeder’s JavaScript API exposes for the web page to call. It allows you to use your existing ways of identifying website visitors within the Leadfeeder app.

Some examples of existing ways of identifying visitors:

  • A website visitor logs to a web app (e.g. SaaS tools)

  • A website visitor logs in to a webshop/intranet/portal

The benefits of using the Leadfeeder Identify Call are many:

  • It improves the company identification that Leadfeeder does for your account.

  • You’ll see identified individuals in Leadfeeder.

  • You can filter identified companies based on them having identified individuals attached by using the Identified visitors filter type in a Custom feed. However, identified visitors can be set only as "is any" or "is none", not as specifically identified visitors.

Once the Leadfeeder Identify Call is triggered, the visitor in question appears on the People tab:

Also, the identified visitor and their company appear on the Companies tab:

The Activity, or visit details, of an individual would look like so:

With the Leadfeeder Identify Call it's possible to identify also website visitors that use a home or mobile phone Internet connection.

Here is how to implement the Leadfeeder Identify Call

Once your web app/portal/webshop is aware of the visitor logged in you’d need to call identify() with the visitor’s email address.

Identify() exists under the window.ldfdr -object on the page. Therefore, make sure your web app/portal/webshop has the Leadfeeder tracking script installed.

Please note: Using this feature requires making changes to your website code. If you aren't confident doing this, please ask your website developer to help you further.

Identify() requires the `email` parameter to be present, and you can optionally pass `firstName` and `lastName` too. Below is a full call signature for identify:

<script>
window.ldfdr.identify({
email: "email@example.com",
firstName: "first name",
lastName: "last name"
});
</script>

Please note: When using the Leadfeeder JavaScript API it is good to keep in mind that the Leadfeeder Tracker supports multiple trackers on one page. The methods in the JavaScript API are designed so that, by default, the behaviour is applied to all trackers. However, you can call them for specific tracker instances only.

How to add Leadfeeder Identify Call to Google Tag Manager (GTM)

To send identity information from GTM, you can use a custom HTML tag. You naturally need to have the Leadfeeder Tracker installed too, either as a custom HTML tag or using the Leadfeeder template from the GTM template gallery. You need to ensure that the firing order is correct, the Leadfeeder tracker tag should always be fired before identify is called.

Example tag configuration:

The above assumes you have a Tag Manager variable called currentUser.email available. There are multiple ways to capture values into variables in GTM: you can take it from some page element (DOM element variable), read a JavaScript variable, or read the value from GTM’s DataLayer.

If you use the DOM element variable you need to define which element from the DOM is the email (the backend must embed the email in the DOM when constructing the webpage for this to work). The DOM element variable will work only if the email is already part of the DOM.

In case the logged-in user’s email address gets retrieved asynchronously (AJAX) from your site’s backend, then you need also to have the following setup:

STEP 1: On every pageview, the backend pushes currentUser.email to GTM’s data layer when available and after that triggers an event for “email-loaded”. Check-in your backend that the event is triggered properly to GTM.

STEP 2: GTM has a variable where currentUser.email gets stored from the data layer.

STEP 3: GTM has the Trigger type Custom event, where the event name it listens for is “email loaded”.

STEP 4: Finally, the Tag for triggering identify() utilizes the variable and Trigger created above.


How to add Leadfeeder Identify Call to WordPress

To send identity information from a WordPress website, please follow these steps:

STEP 1: Open the footer.php in your theme editor. When in the WordPress dashboard, navigate to Appearance > Theme Editor > Theme Footer (footer.php).

STEP 2: Copy paste the following code right before the </body> closing tag

<?php
if ( is_user_logged_in() ) {
$current_user = wp_get_current_user();
$current_email = $current_user->user_email;
$current_first = $current_user->user_firstname;
$current_last = $current_user->user_lastname;
?>
<script>
setTimeout(function(){
window.ldfdr.identify({
email: "<?=$current_email?>",
firstName: "<?=$current_first?>",
lastName: "<?=$current_last?>"
});
}, 500);
</script>
<?php }?>

STEP 3: Confirm changes by clicking on "Update File".

--

Questions, comments, feedback? Please let us know by contacting our support team via live chat or by sending us an email at support@dealfront.com.

RELATED:

Did this answer your question?