Rich-text Reply
Highlighted

Query audiences a visitor is in via js

CouchPsycho 3w ago
Accepted Solution

Query audiences a visitor is in via js

Hi,

 

maybe i just have a bad day but i can not find any info in the docs how to query via the js api to which audiences a visitor belongs, which means which audience conditions he meets.

 

I just want to check if a specific visitor is part of an audience or not.

 

Help is highly appreciated :-)

Kind regards

Michael


   
0 Likes
0 Likes

Re: Query audiences a visitor is in via js

Hi Michael,

There isn't a JS API for getting the audiences a visitor has qualified for but you can see this information in the Optimizely log by adding ?optimizely_log=true to the URL. The log will show you all the activity taking place in the snippet including which audiences a visitor has or has not gotten into. Please see the article below for more information on how to read the log.

https://help.optimizely.com/QA_Campaigns_and_Experiments/Read_the_Optimizely_X_log

Regards
Manny
Optimizely
0 Likes
0 Likes

Re: Query audiences a visitor is in via js

Hi @CouchPsycho ,

Surely this is "not supported" and may "change at any time without telling us", but some audience information is available in localStorage.

 

optimizely_data$$<User Id>$$<account>$$layer_states

 

In this array of objects, if decision.experimentId is not null, and you have any audiences attached to your experiment, you should see the audience ids in the array located at decisionTicket.audienceIds.

--Jason Dahlin
Analytics and Testing Guru Smiley Happy


Experimentation Hero
0 Likes
0 Likes

Re: Query audiences a visitor is in via js

Hi @JasonDahlin , @mansoor-omar 

 

thank you for your advice and hints. Using the local storage works fine for me and creates some interesting ideas how to use that in custom audience definitions :-)

 

 

Kind regards

Michael


   
0 Likes
0 Likes