same contacts are assigned to multiple logged in users

harshal bundelkhandi asked on June 1, 2020 09:28

Hi Support, I am working on marketing automation process for the customer birthday reminders & abandoned shopping cart. Below is scenario :

Customer is come to the website. he added some products to shopping cart after that he logged in anonymous contactID is assigned to the customer ShoppingCartID is generated & assigned to the customer. now customer logoff from the site. now customer have logged in from anotherID. he added some products to the cart. now after the scheduled time for shopping cart abandoned. Customer has received 2 email on the first logged customer emailID.

As i have seen in administration contact management for contact customer first email address is assigned.

Can you help me on this.

Thanks, Harshal

Correct Answer

Dmitry Bastron answered on June 1, 2020 09:51

Hi Harshal,

Yes, you are right, by default Kentico strangely merges multiple contacts to the same user on login. But this can be customized in the code. Basically, you need to:

Implement ICurrentUserContactProvider interface (you can copy Kentico's default implementation DefaultCurrentUserContactProvider to begin with) Amend the logic of GetContactForCurrentUserAndContact method. For example, you can check here if current contact's email is not equal current user's email - return null and Kentico will create a new anonymous contact for that user. Or try to find existing contact for user's email, it's up to you. This code will be called on login before assigning the contact.

Register your custom implementation like this:

RegisterImplementation(typeof(ICurrentUserContactProvider), typeof(CustomCurrentUserContactProvider))]

And that's it.

0 votesVote for this answer Unmark Correct answer

   Please, sign in to be able to submit a new answer.