Thanks for contributing to the script!
For your questions:
- What do you recommend to set as the UserID?
So, Segment recommends using something like a databaseID as the user ID. They do not recommend using email as this is a user property that can change (a user can change their email).
So the way I solved this, was to set up a Segment Function that was triggered using the Webflow Form Webhook to send the form data to Segment Functions, which from there could call our backend to create a userId from the user email submitted in the form.
This is why in my original script, I do not include identify because I did the identify from Segment Functions with the data being passed through the Webflow Form Webhook.
The reason for this, is because doing client-side API-calls to your backend, is both a security issue as well as often blocked client-side.
But of course, the easiest way would just to use email as the userID to save you all of the above trouble.
- How do you dynamically pass in a variable to set the UserID as what you are recommending?
Then you need to know what userID you’re looking for, and where it is in your form. So if you want to use email as the userID, or even the anonymousId as the userID, you can also pass these.
I collected the anonymousId using this code:
let user, anonymousId;
analytics.ready(function () {
user = analytics.user();
anonymousId = user.anonymousId();
});
There are so many ways to identify a user, the most important is that it is aligned with how you generally identify users in your system.
- Segment, in their docs, mention I need to set “Salesforce”: true in an integration object in order to send the
Identify call to Salesforce, but I can’t find anywhere HOW to do that! Do you know how insert that into the below javascript? (Salesforce Destination | Segment Documentation)
You can do this:
analytics.identify({
integrations: {
All: false,
Salesforce: true,
},
});
This will only send data to Salesforce, and no other destinations.