Skip to main content

Sona Identify () for Web Apps

How to implement the optional Sona Identify script to send authenticated user data, connecting an anonymous visit to a known user across your web app.

Overview

Sona provides an optional script you can add to your website or app to send user data. This Sona Identify () script connects the journey for users who visit your website and later submit registration information, so an anonymous visit and a known user become a single continuous profile. To implement it, your development team dynamically populates the placeholders (USER_EMAIL, firstName, lastName, and others) with actual user data from your application's database or session at runtime.

Step 1: Identify the data source

The values for email, id, leadId, firstName, lastName, and phone should come from authenticated user data available on your platform.

Step 2: Push the email

The email is the key identifier, and a few optional fields can enrich it:

  • Email: pushing an email identifier is essential for accurate user identification. Replace 'USER_EMAIL' with the user's actual email address.

  • Optional fields: additional information such as firstName, lastName, leadId, and phone provides enhanced tracking and is beneficial when available.

Step 3: Populate the values dynamically

  • Insert values by dynamically passing user-specific data within the HTML <script> tag.

  • Ensure these values are securely accessed from your backend or session data to prevent exposing sensitive information in the script.

For example, using a templating language:

<script type="text/javascript">
sona.identify({
email: '<%= currentUser.email %>', // Replace dynamically

leadId: '<%= currentUser.leadId %>', // Optional
firstName: '<%= currentUser.firstName %>', // Optional
lastName: '<%= currentUser.lastName %>', // Optional
phone: '<%= currentUser.phone %>', // Optional
});
</script>

Or, using JavaScript variables directly:

<script type="text/javascript">
sona.identify({
email: user.email, // Replace dynamically

leadId: user.leadId, // Optional
firstName: user.firstName, // Optional
lastName: user.lastName, // Optional
phone: user.phone, // Optional
});
</script>

Note: ensure the data is securely managed and sent according to your organization's data protection practices, especially when displaying user data within front-end scripts.

FAQs

Why is the email field required?

The email address is the identifier Sona uses to match a known user to their earlier anonymous activity. Without it, Sona cannot reliably connect a registration or login to the visits that came before, so the email field should always be populated with the user's actual address at runtime.

Which fields are optional?

Beyond email, the firstName, lastName, leadId, and phone fields are optional. They are not required for identification, but including them when available gives you richer tracking and a more complete profile for each user.

Do I have to use Sona Identify to use Sona?

No. Sona Identify is an optional addition to the standard tracking script. The standard SDK already tracks anonymous visitor activity. Sona Identify is what links that anonymous activity to a known user once they register or log in, which is especially valuable for web apps with authenticated areas.

Did this answer your question?