Reading Triggered Experiment Data for Using it in Third Party Systems

This Article Will Help You:


Understand Triggered Experiment Data

You might want to access the running experiment’s data or the data of all experiments that were triggered for a specific visitor in order to push them in external tracking systems. For that we make available two Javascript objects:

convert.currentData

This holds all the items that were triggered on the specific page where the object is read: experiments, goals. The structure of this object is the following:

  • experiments - this holds all the experiments that are currently running on the current page. The keys of this objects are the experiments IDs and the values are objects containing the following data:
    • variation_id - the ID of the variation picked and presented for the specific experiment;
    • variation_name - the name of the variation presented, as found in the convert experiments app report for that specific experiment; If the data anonymization feature is enabled, this name will look something like "Var #variation_ID" where variation_ID is the ID corresponding to the variation, as found inside Convert Experiments App;
    • first_time - Boolean value indicating whether the experiment is triggered for the first time (for this visitor) on this page or it was triggered also before this hit.
    • variation_name_parts - object that contains parts of the variation name, only useful in the case of a Multivariate test. For an A/B or Split URL test this object contains the same data as the “variation_name” field. This is a two elements object that contains the following keys:
      • sections : array of names of sections as defined inside the Convert Experiments app visual editor. For A/B and Split URL tests,“sections” has only one element with a value of empty string “”; If the Data Anonymization feature is enabled, this names will not be filled in, but contain just empty strings.

      • changes : array of names of all the changes as defined inside the Convert Experiments app visual editor; If the Data Anonymization feature is enabled, this name will not be filled in, but contain just empty strings;

  • goals - object that contains all the goals triggered on the current page. The keys are goals IDs as found inside convert experiments application and the value is always 1. This object can change after page loads since more goals could be triggered afterwards - example goals that track clicks.

  • experiments_goals - mainly it has same content as the "goals" but in a different structure.

Here is an example of how this object would look like:


{
"goals": {
"10001841": 1
},
"experiments": {
"10001236": {
"variation_id": 10008683,
"variation_name_parts": {
"sections": [""],
"changes": ["Original Page"]
},
"variation_name": "Original",
"first_time": false
},
"10001237": {
"variation_id": "10008687",
"variation_name_parts": {
"sections": [""],
"changes": ["Original page"]
},
"variation_name": "Original",
"first_time": true
}
},
"experiments_goals": {
"10001237": {
"10001841": 1
}
}
}


And this is how it looks like in Google Chrome Console:

convert.historicalData

This object contains data gathered across all past visitor session. Currently it only has one key:

  • experiments - holds all experiments triggered for the visitor; the keys are experiments ID’s and the values are objects with the following structure:
    • variation_id  - ID of the variation selected for the experiment;
    • variation_name - name of the variation; If the Data Anonymization feature is enabled, this name will look something like "Var #variation_ID" where variation_ID is the ID corresponding to the variation, as found inside Convert Experiments App;
    • goals - object that holds goals triggered for the current experiment; keys represent goal ID’s and values are always 1;

Example of this object would look like :


{
"experiments": {
"10001236": {
"variation_name": "Original",
"variation_id": 10008683,
"goals" {
"10001841": 1
}
},
"10001237": {
"variation_name": "Original",
"variation_id": "10008687",
"goals": {
"10001841": 1
}
}
}
}


This is how it looks like in Google Chrome Console:

_conv_q variable

Due to the fact that some parts of the tracking script can be async (for example an experiment that uses geo location data for targeting will be triggered in a async way), we advise reading any of this data inside functions that are executed through the use of the Convert queue variable: _conv_q

Example:

_conv_q = _conv_q || []; 

_conv_q.push([function(){

//your script that handles the data here  

}]);

Like this, you can place the script anywhere on page and the function will be executed right after all experiments and goals were triggered so that all the data is available.

Example

You can use the example located in this article to create your own integration.

 

keywords: "send data"