Rich-text Reply

REST API addtocontacts

hemang 09-01-15

REST API addtocontacts

Hi 

 

 

Like Javascript API window['optimizely'].push(['addToAudience', audienceId]); can I do same in PHP REST API?

 

I mean using PHP REST API can I add audience using API token 

 

 

Waiting for reply 

 

 

Thanks in Advance 

 

 

 

Level 2

bigspencey 09-01-15
 

Re: REST API addtocontacts

Hi Hemang,

 

Thanks for reaching out to us. Unfortunately, we don't currently have the ability to add individual visitors to audiences via the REST API. You can read, create, and update existing audiences, but on a visitor by visitor basis you'll need to use the JS API above Optimizely's snippet for audience assignment.

 

Let me know if you have any questions about the above and I'm happy to dive deeper where/if needed!

 

Best,

Spencer

Optimizely
hemang 09-02-15
 

Re: REST API addtocontacts

Hi Spencer

Thanks for reply


If it's not possible using REST API then I would like to go with JS API

Using JS API addtoAudience can I do following things

1. get to know count to visitors added ?
2.For specific audience if conditions don't match, then also I can add ? For example I have set condition like if in query abc=xyz then show the experiment otherwise not. If this condition does not match and on page I have called addtoaudience funtion then it will add or not ?

Thanks
Hemang
Level 2
bigspencey 09-02-15
 

Re: REST API addtocontacts

Hey Hemang,

 

1. We could potentially use a custom event to document visitors that were added to the audience.

 

For example:

if (/* some condition */) {

  window['optimizely'] = window['optimizely'] || [];

  window['optimizely'].push(['addToAudience', <audience_id>]);
  window.optimizely.push(["trackEvent", "<count_visitor_event_name>"]);

}

 

This solution would give you a count on the results page of all the unique visitors added via that API.

 

2. The addToAudience call will override Optimizely's default behavior so even if the visitor doesn't qualify for the condition, then using this API call will force them in.

 

If I misunderstood what you're asking just let me know and I can elaborate where needed!

 

Best,

Spencer

Optimizely