adobe / helix-home

The home of Project Helix
54 stars 84 forks source link

Personalised content and Real Time Context #214

Open kptdobe opened 3 years ago

kptdobe commented 3 years ago

https://github.com/adobe/express-website-issues/issues/158 is the first time we see the need for conditional content: the popup must be shown when returning/web app visitors click on the individual plan for m2m (audience).

In Helix terms, the popup is a block and the block would be shown only if the surfer is currently part of the audience, which is determined by Adobe Audience Manager (AAM).

The requirements are:

Specifications:

The first idea to explore to associate a block with an audience is to allow any block to have a first row like:

Block Name
Audience audienceID_XYZ
Block content ...

The "audience row" would be extracted before block handling logic which means the block code would receive the same dom as before. This gives an easy way for authors to edit the block - audience relationship. An "audience" picker could even be built to even make it smoother.

Then we'll need some logic that would bridge the audiences from AAM and some global object containing the current context of the surfer (the Real Time Context (RTC :)) and providing a way to determine which block must be shown / loaded or not.

cc @davidnuescheler @trieloff @rofe

trieloff commented 3 years ago

An "audience" picker could even be built to even make it smoother.

The idea is that https://github.com/adobe/helix-sidekick/issues/64 would work as an audience picker when invoked from within Word or Google Docs:

Edit

The same dropdown will be shown, but without an option to clear or set the audience, instead clicking an audience name will copy the audience ID so that it can be used in the first column of the personalization block's table

trieloff commented 3 years ago

Then we'll need some logic that would bridge the audiences from AAM and some global object containing the current context of the surfer (the Real Time Context (RTC :)

That would be the window.hlx.audience and window.addEventListener('helix-audiencechanged', (evt) => console.log(evt.detail); outlined in https://github.com/adobe/helix-sidekick/issues/64#issuecomment-903138777

trieloff commented 3 years ago

The "audience row" would be extracted before block handling logic which means the block code would receive the same dom as before […] and providing a way to determine which block must be shown / loaded or not.

Wouldn't it be better to encapsulate the entire logic of calling Audience Manager and showing/hiding rows (using display: none) in the "Personalization Block" component? For one, we won't have an additional global state and second-order dependencies like (only load the AAM integration when the personalization block is on the page). On the other hand, this will make toggling audiences with adobe/helix-sidekick#64 easier, as you only have to flip the display: none/block style.

kptdobe commented 3 years ago

If you do a "Personalisation Block" (I made a prototype, that's the first I have done :) ), you will need to put the other blocks inside - or make a "Personalisation Block flavour" for all your blocks that you want to have personalised.

kptdobe commented 3 years ago

window.addEventListener('helix-audiencechanged', (evt) => console.log(evt.detail);

I know by experience that this is the start point of an event mess: everybody listens and everybody fire events on each change. The time for all 3rd party dependencies to be loaded (AAM, Target...), you changed the page content a gazillion of time. I am not saying we should not do it like this but we should try different approaches before defining the technical solution.

trieloff commented 3 years ago

Given that we have only one personalization use case so far, I'd be fine with having one single personalizable block over the more general solution.

kptdobe commented 3 years ago

The reason we design it event base (I built the feature 2 times already that way...) is because we start by the simulation: you want to update the page on each change. I "hope" that if we start by the content loading sequence, we can avoid it and not over-engineer it.

kptdobe commented 3 years ago

Given that we have only one personalization use case so far, I'd be fine with having one single personalizable block over the more general solution.

That's definitively a fair point ;)