Try our conversational search powered by Generative AI!

Programmatically assign visitor group?

Vote:
 

How can I programatically assign a visitor group to a user from C#?

I have an iFrame on a page that contains some 3rd party application process (like applying for a loan).  When a user begins the application but leaves without finishing it, I want to detect this in JavaScript and make an Ajax call out to the backend informing it of what is occuring.  The backend controller action should programatically assign a custom visitor group of 'Prospect' to the current user.  Is this possible?

#194765
Jul 02, 2018 15:29
Vote:
 

Hi Dylan, have you read about how to create your own visitor group in the developer guide? Just asking because you are talking about assigning visitor to a group instead of evaluating visitor for some criteria X.

I'm assuming the visitors are anonymous(?) users (not signed in so that you would actually know who they are). So I think in your case the simplest client side approach would be to create a cookie when the user for example starts the loan application and you create a cookie for example with value "prospect" on the client side and depending the process remove the cookie when loan application is submitted or set some other state value that you can later use.

Then implement your own visitor group criteria where you check if the user has the cookie with value "prospect" so then you know you can have these users in the "prospect" visitor group (that you create with the criteria you implement). If your process can have differnt states then you propably implement the visitor group criteria in a way that editor (visitor group admin member) can create different actual visitor groups with the criteria.

Hope this helps or if I understod your question wrongly then please clarify your needs a bit more.

#194770
Jul 02, 2018 16:03
Vote:
 

Hi

I think you are viewing the visitor groups a bit backwards. A user is never directly assigned a visitor group. Instead, whenever a particular visitor group is required (an IsInRole call is made) the logic for that particular type of visitor group will be evaluated and a bool will be returned, indicating if the user is part of that group. That value is not persisted, instead the logic is re-run for each check. And it has to be as for the next time that visitor group is evaluated for the same user, it might yield another result (consider for example the time and place visitor group).

For your scenario, one approach could be to store a value in any kind of data store when the Ajax request is made. The value would be that the current user has fulfilled the scenario, in this case left without finishing. You could then make your own custom visitor group which checks the stored data and makes a decision if a particular user is a member of the group.

Here is an example of a custom visitor group, https://world.episerver.com/documentation/developer-guides/CMS/personalization/example-create-your-own-visitor-group-criteria/.

Regards

Per Gunsarfs

Edit: Or what Antti just said :)

#194771
Edited, Jul 02, 2018 16:05
Vote:
 

Thanks guys!

I will follow the cookie approach, seems like a good way to go.

#194772
Jul 02, 2018 16:57
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.