setShopper()

If the customer has logged in and has been identified by your platform or system then you can tell Fera who they are to link the Shopper profile to the customer profile.

Basic Way (Recommended)

Fera is all about personalization and creating better customer experiences, so there's very little to gain for a hacker if they pretend to be someone else, especially since the updates will always be scoped to the current shopper's session only.

fera.push('setShopper', {
customer_id: "customer-123",
name: "John Doe",
email: "john.doe@example.com",
country_code: "US",
region_name: "California",
city_name: "Orange County",
zip: "78730",
favorite_color: "red",
shirt_size: "medium"
});

Any attributes you set that are not from the base Shopper Model Data Schema are automatically considered custom attributes and will be stored as such.

See the Shopper model data schema reference to see what basic attributes you can set here.

If you're setting customer data this way then you should avoid displaying customer names, emails and other personally identifiable attributes in your personalization skills.

Also see:

Minimum Way

If you're already sending the customer info with your order_create events then you only really need to specify who the current customer is by their customer ID.

fera.push('setShopper', {
customer_id: "customer-123"
});

More Secure Way (Advanced)

That being said, if you want to be extra safe you can pass an encrypted token to Fera for the customer ID instead, and Fera won't update shopper details unless the encrypted token matches your API secret key.

Locating your secret key

In order to set the currently shopping customer you will need your SECRET_KEY which can be found in your account here.‚Äč

Go to Store Settings -> API

Do not display this secret key to anyone and make sure it does not show up in your javascript code or HTML! It should only be stored on your server privately and securely.

After you've obtained your secret key, you can generate your ID token you can set it to the customer_id_token attribute in the api call.

Ruby (.erb)
Other Languages

Assuming your customer is in current_user and your customer ID is current_user.idthen your code might look like:

<script type="application/javascript">
__bsio.push('setShopper', {
customer_id_token: "<%= current_user.id.to_s.encrypt(:symmetric, password: 'SECRET_KEY_GOES_HERE') %>",
name: "John Doe",
email: "john.doe@example.com",
country_code: "US",
region_name: "California",
city_name: "Orange County",
zip: "78730",
platform_data: { platform_attribute: "Platform Value" },
favorite_artist: "Nirvana"
});
</script>

Let us know what other languages you want to see here by contacting our team!

Also see: