Rich-text Reply
Highlighted

OPTIMIZELY: Experiment key my_experiment is not in datafile.

mmarinescu 10-12-17

OPTIMIZELY: Experiment key my_experiment is not in datafile.

Hello,

 

I'm trying the example from here: https://developers.optimizely.com/x/solutions/sdks/getting-started/index.html?language=javascript while using AngularJs.

 

Here is my datafile: https://cdn.optimizely.com/json/9008000440.json

Formated JSON:

{
  "groups": [],
  "projectId": "9008000440",
  "experiments": [
    {
      "status": "Archived",
      "audienceIds": [],
      "variations": [
        {
          "id": "9011691724",
          "key": "default_optimizely"
        },
        {
          "id": "9012501321",
          "key": "other_optimizely"
        }
      ],
      "id": "9015491476",
      "key": "melville_test",
      "layerId": "9014620805",
      "trafficAllocation": [
        {
          "entityId": "9012501321",
          "endOfRange": 5000
        },
        {
          "entityId": "9011691724",
          "endOfRange": 10000
        }
      ],
      "forcedVariations": {}
    },
    {
      "status": "Running",
      "audienceIds": [],
      "variations": [
        {
          "id": "9017401360",
          "key": "default"
        },
        {
          "id": "9033700715",
          "key": "treatment"
        }
      ],
      "id": "9032590490",
      "key": "my_experiment",
      "layerId": "9022951062",
      "trafficAllocation": [
        {
          "entityId": "9017401360",
          "endOfRange": 5000
        },
        {
          "entityId": "9033700715",
          "endOfRange": 10000
        }
      ],
      "forcedVariations": {}
    }
  ],
  "audiences": [],
  "version": "2",
  "attributes": [],
  "accountId": "9008000440",
  "events": [
    {
      "experimentIds": [
        "9032590490"
      ],
      "id": "9012410929",
      "key": "my_conversion"
    }
  ],
  "revision": "9"
}

 

Here is my Angular code:

var optimizelyClientInstance;
        var optimizelyClient = window.optimizelyClient;;

        $http({
            method : "GET",
            url : "https://cdn.optimizely.com/json/9008000440.json",
            params: {
                mode: "cors"
            }
        })
        .then(function (datafile) {
              optimizelyClientInstance = optimizelyClient.createInstance({ datafile: datafile })
            var variation1 = optimizelyClientInstance.activate('my_experiment', 'joe');
            var variation2 = optimizelyClientInstance.activate('my_experiment', 'jill');

            console.log('variation1: ', variation1);
            console.log('variation2: ', variation2);
        })
        .catch(function(err) {
            console.log(err)
        });

 

But in the console, I get this error:

optimizely.min.js:1 [OPTIMIZELY] - INFO Thu Oct 12 2017 13:20:19 GMT+0300 (GTB Daylight Time) OPTIMIZELY: Experiment key my_experiment is not in datafile.

variation1:  null
variation2:  null

Below, a picture from the consoleScreenHunter_87 Oct. 12 13.37.jpg

 Needless to say that the get datafile and optimize calls work:

ScreenHunter_89 Oct. 12 13.39.jpg

 

 

 

Could you please advise why I get this error?

 

Thanks in advance

 

tedroddy 10-13-17
 

Re: OPTIMIZELY: Experiment key my_experiment is not in datafile.

Hi there,

Can you check and see what values you have for datafile and optimizelyClientInstance.configObj within your then()? Is the experiment in there? And do you have a link where we can reproduce this issue?

Best,
Ted
Optimizely
mmarinescu 10-16-17
 

Re: OPTIMIZELY: Experiment key my_experiment is not in datafile.

Hello Ted,

Unfortunately I deleted the code. Anyways, probably there was a gulp setup issue, as I've used the fullstack solution in a nodejs project and the calls worked.

Finally I decided to go via the Optimizely X Web solution as it provides more control for the customer.

Thanks,