Once you have deployed the Convizit JavaScript tag, you may add JavaScript code to your website that associates your customer IDs with known visitors. You may optionally include additional data fields that Convizit will save along with each visitor. This may make it easier to consume the user activity data available in your systems.
This page describes how to implement the following code snippets:
Client-Side Customer Identification
If you want Convizit to include your own customer IDs when delivering your visitor activity data, you need to execute the following JavaScript function in your website whenever a visitor logs in or registers:
convizit.identify('');
Replace <your_customer_id>
with JavaScript code that resolves to a unique identifier for the current visitor, such as the customer ID that appears in your database or a hash of the customer email address (for data privacy reasons, it is not recommended to use actual email addresses or any other type of PII).
When your customer ID is associated with website visitors in this way, all user activity data supplied by Convizit will also include your customer ID.
Saving Additional Customer Details
After associating a customer ID using convizit.identify()
you may also send Convizit additional data fields that Convizit will save along with each visitor record. This may make it easier to consume the user activity data in your own systems (again, it is recommended to only provide hashed values of fields containing PII). To do so, execute the following JavaScript function in your website:
convizit.set('visitor_details', {
$email: '',
$first_name: '',
$last_name: '',
$date_time: '',
some_number_field: ,
some_boolean_field: ,
...
});
Notes:
- All fields are optional.
- The four field names that start with $ are “reserved” field names.
- The
$date_time
field is intended for any date/time related to the individual customer. Common uses include the date/time that the customer first appeared in your customer database or the customer’s birthday. It should be provided in Unix epoch time format. - Up to 50 fieldname:value pairs may be specified.
- Field names must be strings (maximum 255 characters).
- Values must be of type string (maximum 255 characters), number or Boolean.
Retrieving Saved Customer Details
If you would like to be able to access, via client-side JavaScript, the customer details that you previously associated with the current website visitor (using convizit.set(‘visitor_details’,{…})), use the following JavaScript function:
var userProfile = convizit.get('visitor_details', function callback(visitorDetails){});
This function returns an object containing the available fieldname:value pairs for the current website visitor:
{
'visitor_id': '',
'customer_id': '',
'$email': '',
'$first_name': '',
'$last_name': '',
'$date_time': '',
'some_number_field': ,
'some_boolean_field': ,
...
}
Where:
-
visitor_id
is Convizit’s unique identifier for this visitor. customer_id
is your identifier for this customer, as previously associated with this visitor using the convizit.identify() function.- all other field names and values are those previously associated with this visitor using the convizit.set(‘visitor_details’,{…}) function.