unrvld / odp.visitorgroups Goto Github PK
View Code? Open in Web Editor NEWVisitor Groups for Optimizley Data Platform
License: MIT License
Visitor Groups for Optimizley Data Platform
License: MIT License
For the example visitor group, Any account with first name ‘Admin’ should be apart if the visitor group. Verifying the information on ODP, the user [email protected] should be apart of the group
However this user doesn't trigger the group when used to personalize content or show on our user-debug page where we list out our visitor groups that a user matches.
Our Configuration:
"OdpVisitorGroupOptions": {
"OdpCookieName": "vuid",
"CacheTimeoutSeconds": 1,
"OdpEndpoints": [
{
"Name": "US", //Unique name for the instance
"BaseEndPoint": "https://api.zaius.com",
"PrivateApiKey": "[Key]"
}
]
},
From startup.cs
public void ConfigureServices(IServiceCollection services)
{
// set the data directory
AppDomain.CurrentDomain.SetData("DataDirectory", Path.Combine(_webHostingEnvironment.ContentRootPath, "App_Data"));
// configure application cookie
services.ConfigureApplicationCookie(options =>
{
options.Cookie.SameSite = SameSiteMode.None;
options.Cookie.SecurePolicy = CookieSecurePolicy.Always;
});
services.Configure<CookiePolicyOptions>(options =>
{
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.Configure<FormOptions>(options =>
{
options.ValueCountLimit = int.MaxValue;
});
// custom configuration
services.ConfigureSerilogLogging(_config);
services.ConfigureAzureServiceBus(_config);
services.ConfigureApplicationServices(_config);
services.ConfigureChadwellIdentity(_config);
services.ConfigurePunchout();
services.ConfigureAssociations();
services.ConfigureGetaNotFoundHandler(_config);
services.ConfigureUploadOptions(_config);
services.AddCms()
.Configure<MvcOptions>(m =>
{
m.ModelMetadataDetailsProviders.Add(new CustomModelMetadataProvider());//custom model attributes for validation in cms admin
})
.AddCommerce() // set up commerce admin, wire up commerce routs for categories and product pages.
.AddFind() // add find admin
.AddFindSearchProvider() // add default find services
.AddAdminUserRegistration()
.AddEmbeddedLocalization<Startup>()
.AddApplicationInsightsTelemetry()
.AddHttpContextAccessor()
.AddMemoryCache()
.AddCmsTagHelpers() //Epi Tag-helpers
.AddSitemaps(x => //geta sitemaps
{
x.EnableLanguageDropDownInAdmin = false;
x.EnableRealtimeCaching = true;
x.EnableRealtimeSitemap = false;
}, p => p.RequireRole(Roles.Administrators)).AddSitemapsCommerce()
.AddCustomFindServices(_config);//register custom find services, run at the end.
services.AddControllersWithViews()
.AddNewtonsoftJson(options =>
{
options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; //Avoid runtime errors serializing page ViewModels with a page reference.
})
.AddMvcOptions(options => options.Filters.Add(
new ResponseCacheAttribute
{
NoStore = true,
Location = ResponseCacheLocation.None
}));
**services.AddODPVisitorGroups();**
services.AddTinyMceConfiguration();
services.AddSingleton<IActionContextAccessor, ActionContextAccessor>();
//Run last to override built in Epi Cart Validation as it doesn't function correctly in Commerce 14.
services.AddTransient<OrderValidationService, CustomOrderValidationService>();
services.AddCors(options =>
{
options.AddPolicy("AllowAll", builder =>
{
builder.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
});
});
}
How we check if a user matches a visitor group on our debug page:
private List GetVisitorGroupByCurrentUser()
{
var filteredVisitorGroup = new List();
var user = HttpContext.User;
var visitorGroups = _visitorGroupRepository.List();
foreach (var visitorGroup in visitorGroups)
{
if (_visitorGroupRoleRepository.TryGetRole(visitorGroup.Name, out VisitorGroupRole virtualRoleObject))
{
if (virtualRoleObject.IsMatch(user, HttpContext))
{
filteredVisitorGroup.Add(visitorGroup.Name);
}
}
}
return filteredVisitorGroup;
}
I have gotten the 'is in segment' to work, but not the 'Customer property - Text' nor 'Customer property -Number' criteria. Do you have any idea why these criteria are not working?
I've created an Audience (Visitor Group) based on an ODP RTS. When I assign that Audience to content in the CMS, it's showing/hiding the content based on the opposite of the rule (showing the content if NOT a member of the RTS, and hiding when you ARE a member).
For ex:
Expected result:
Actual result:
Looking at the code, the issue appears to be here:
https://github.com/unrvld/ODP.VisitorGroups/blob/main/src/UNRVLD.ODP.VisitorGroups/Criteria/CustomerDataRetriever.cs#L136
It will return TRUE (edges.count == 0) when you're not a member, and FALSE (edges.count == 1) when you are a member.
About to submit a PR for review.
I have observered that some customers that are part of a Real Time Segment in ODP are not being matched to a paired CMS visitor group.
I have debugged the issue via the GraphQl explorer and uncovered that when this happens, their vuid does not exist in ODP... and I also note that your library tries to match customers to ODP Real Time Segments (or audiences) by their vuid.
I'm not quite sure what's going on here. My best guess (and I could well be wrong) is that when ODP stitches customer records across different sessions, devices, browsers etc, it discards all but one of the vuids. If the vuid I have stored in my cookies is not the one kept against my customer record in ODP then I cannot leverage personalization via your package.
Not sure I'm making sense... so here's an example...
Joe Bloggs visits a website on his phone. This website is using OPD and Optimizely CMS and linked-up using your package. When he visits the site for the first time, this creates a cookie with a 'vuid' in his phone and sends its value to ODP with all subsequent requests. Joe later registers on the site and his email is captured in ODP. At this point, Joe's customer record in ODP contains his email and his 'vuid'.
Later on, Joe visits the same website on his desktop. This creates a new cookie with a new vuid in his desktop and sends this to ODP with all subsequent requests. Joe then signs-in on the website via his desktop and his email is again captured in ODP. At this point, ODP has two 'vuid' values that can be attributed to Joe Blogs' customer record.
If ODP keeps the value from his phone against his customer record (and discards the other), then when he browses from his desktop, he will never match the odp audience and never get a personalized experience via the cms visitor groups.
Does this all make sense? Am I missing anything?
This would seem like a big problem with ODP and personalization, i.e. not being able to do personalization across different channels.
I think for your package to get around it, ODP would need to expose a list of vuids against each customer and allow your package to query that.
Is there a way around it that you can see?
Thanks in advance
Dan
We've recently updated our solution to the latest version (1.0.8) of RestSharp but now can no longer access the VistorGroups tab in the CMS.
When I remove this package I can access visitor groups as expected.
The error we receive is:
Could not load file or assembly 'RestSharp, Version=107.3.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
A client of mine is looking into using this add-on. During testing, I have found some queries to be slow and wrote some changes.
However, I am missing push access to push a feature branch in order to make a PR.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.