Using Relevance Module with Angular SPA SDK

Goal:
We want to use the relevance module to track users coming into the application

What we have done:
Installed the essentials modules for Relevance Tracking
Created an experiment to test if a user returned back to the site

What we are seeing:
When hitting the ‘localhost:8080/cms/_targeting/visitors’ we see that the user’s data is coming in, however, they are all under a different visitor id. We are not seeing a ‘_visitor’ cookie being dropped which may explain that.
Looking at the SPA SDK GitHub project, it does say the relevance module is supported but using express middleware. Is this actually the approach needed for Angular (not universal or CSR)? That feels wrong.

Has anyone had experience with getting this to work with an angular application? Or any ideas on how to tie the visitor id?

@jasper.floor have you ever seen this before?

The easiest approach is to get the visitor ID from the Page Model API and then store that value in a cookie, such as _visitor. If you access the Page Model API directly in the browser, you will see that the Site webapp automatically sets the _visitor cookie, but since this is a headless implementation, you need to manage the _visitor cookie on the frontend.

Once the _visitor cookie is set, you can read the value and then add it to the br-page configuration object. Example below:

const configuration = {
    endpoint: 'http://localhost:8080/site/resourceapi',
    path: '/',
}
if (cookie.visitorId) {
    configuration.visitor = {
        id: cookie.visitorId,
        header: '_visitor'
    }
}

That makes a ton of sense. Looking at the Angular example, as it is, does this. What is interesting for us, is after creating the cookie, then passing that via the SDK as they have in the example, we are seeing the traffic come in. However, we are noticing that the visitor info isn’t being tracked appropriately. For instance, the new visitor indicators still show as true but the returning visitor is false even though we have the same ID and cookie being used!

We are going to continue to work on things to try and get it working.