Skip to content

Instantly share code, notes, and snippets.

@asaschachar
Last active August 10, 2020 19:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asaschachar/b8c9a67878d38edbf664083d8681a6a2 to your computer and use it in GitHub Desktop.
Save asaschachar/b8c9a67878d38edbf664083d8681a6a2 to your computer and use it in GitHub Desktop.

Exporting Optimizely Event Data

Note: This functionality requires an Optimizely plan with access to "Event Data Export"

The following uses the open source command line tool oevents.

Prerequisites

  • A terminal to run the oevents bash script (any OS X and most GNU/Linux distributions)
  • jq - a command-line processor
  • curl (Note: All versions of OS X starting with Jaguar come with curl installed)
  • The Amazon AWS CLI (v2+)
  • Experiment with data that's at least one day old

Setup the command line script

  1. Download the oevents command line tool here
  2. Place it in a directory of your choosing
  3. Make sure it's executable by opening a terminal to the location in the previous step and calling:
chmod +x oevents
  1. Add oevents to a directory in your PATH environment variable with:
sudo cp oevents /usr/local/bin/
  1. Now we can call the script from the terminal to make sure it's working:
oevents help

Authenticate the command line script

  1. Open Optimizely's application
  2. Navigate to Profile -> API Access
  3. Generate a personal access token and save it in a safe place
  4. Set your personal access token as an environment variable in your terminal with:
export OPTIMIZELY_API_TOKEN=<token>

Exploring your Enriched Event data

Enriched Events are partitioned into two top-level datasets, decisions (type=decisions) and conversions (type=events). Each of these datasets is partitioned by date and experiment (for decisions) or event type (for conversions).

You can use oevents ls to list all of the experiments that produced decision data on a given date:

$ oevents ls --type decisions --date 2020-07-22

                           PRE experiment=10676850402/
                           PRE experiment=14386840295/
                           PRE experiment=14821050982/
                           PRE experiment=15117030650/
                           PRE experiment=17517981213/
                           PRE experiment=17535310125/
                           PRE experiment=8997901009/

You can also use oevents to list all of the event types collected on a given day:

$ oevents ls --type events --date 2020-07-22

                           PRE event=search_query/
                           PRE event=search_results_click/
                           PRE event=add_to_cart/
                           PRE event=purchase/

Downloading your Enriched Event data

You can use oevents load to download your Enriched Event data in Apache Parquet format. Command line arguments can be used to specify a progressively narrower subset of your data.

To download all enriched event data associated with your Optimizely account:

$ oevents load --output ./optimizely_data

To download all decision data associated with your Optimizely account:

$ oevents load \
    --type decisions \
    --output ./optimizely_data

To download all decision data collected between July 1st and 5th, 2020:

$ oevents load \
    --type decisions \
    --start 2020-07-22 \
    --end 2020-07-24 \
    --output ./optimizely_data

To download all decision data for experiment 12345 collected between July 1st and 5th, 2020:

$ oevents load \
    --type decisions \
    --start 2020-07-22 \
    --end 2020-07-24 \
    --experiment 12345 \
    --output ./optimizely_data

View your Exported Data

Use a tool like Visual Studio Code with the Parquet extension to view your parquet data in a more friendly JSON format.

For more Information

oevents open source on Github! You can also read the data specification for Enriched Event Export for more information on the event data format.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment