Movatterモバイル変換


[0]ホーム

URL:


Dev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubDev CommunityOptimizely AcademySubmit a ticketLog InExperimentation Data
Dev Guide
All
Pages
Start typing to search…

Get started

How to configure and get started with the Optimizely Event API.

For a complete description of the Event API, consult theEvent API reference.

Create an experiment

Re-use an existing experiment or create an experiment in the Optimizelyapplication and add at least one event and metric. Make sure you start your experiment before proceeding to the next step. For information on how to create an experiment, see the following documentation:

Optimizely Web Experimentation and Optimizely Performance Edge experiments

Optimizely Feature Experimentation experiments

Collect the required identifiers

The following table shows the required fields to include in the JSON object described in the section,Build the JSON data object.

Follow the instructions in the end-user support article,Find IDs for API calls, to locate these fields.

FieldTypeRequired to activate a userRequired to track event
account_idAccount identifierYesYes
visitor_idVisitor identifierYesYes
timestampEvent timestampYesYes
entity_idEvent entity identifierYesYes
campaign_idCampaign assignmentYesNo
experiment_idExperiment assignmentYesNo
variation_idVariation assignmentYesNo

Build the JSON data object

The JSON data object structure differs depending on whether you want to activate a user to a variation or track conversion events.

❗️

Warning

A single JSON object must be3.5 MB or less.

Activate users

To activate a user to a variation, send a JSON object that includes:

  • Thedecisions array, containing thecampaign_id,experiment_id, andvariation_id.
  • Theevents array, containing a special event of type,campaign_activated that represents the visitor being bucketed to a particular variation. By convention, this event'sentity_id is mapped to the corresponding variation'scampaign_id as given in thedecisions array.
  • Theenrich_decisions field set totrue to enable Optimizely's Experimentation Events Export functionality. For information about this field, see theEvent API reference. Also, seeHow Optimizely Experimentation counts conversions.
📘

Note

  • Thecampaign_activated event must have atimestamp equal to or older than other tracked conversion events, as explained inHow Optimizely Experimentation counts conversions. Any conversion events with timestamps older than the related decision event will not be counted on theresults page.
  • A single visitor can only be exposed to one variation of one experiment within a campaign. Ensure that eachcampaign_activated event for a given visitor is mapped to only onecampaign_id,experiment_id, andvariation_id triplet.
  • You do not need to activate a user if they have already been activated by a Feature Experimentation or Web Experimentationactivate() call.

The example includes the optionalclient_name andclient_version fields. Include these fields for debugging.

{  "account_id": "1887578053",  "visitors": [    {      "visitor_id": "test_user",      "snapshots": [        {          "decisions": [            {              "campaign_id": "9560823711",              "experiment_id": "5733750339",              "variation_id": "6630810318"            }          ],          "events": [            {              "entity_id": "9560823711",              "type": "campaign_activated",              "timestamp": 1491519130343,              "revenue": 9900,              "uuid": "12a25c92-7edd1-1c30-21a8-aa4c850671e4"            }          ]        }      ]    }  ],  "anonymize_ip": true,  "client_name": "Optimizely/event-api-demo",  "client_version": "1.0.0",  "enrich_decisions": true}

Track conversion events

Aconversion event represents a visitor taking a specific action on your site.

Ifenrich_decisions is true, the activation information for each visitor is retained (meaning thecampaign_id,experiment_id, andvariation_id). Subsequent conversion events are automatically matched to the appropriate variations.

See theActivate users section for information about theclient_name,client_version, andenrich_decisions fields in the following code example.

You should include attributes for conversion events. Adding attributes lets yousegment your results properly.

📘

Note

  • You still need to pass an emptydecisions array, as shown in the example below.
  • The conversion event must have a timestamp equal to or more recent than the timestamp of thecampaign_activated event, as explained inHow Optimizely Experimentation counts conversions. Any conversion events with timestamps older than the relatedcampaign_activated event will not be counted on the Results page.
  • Within a session, events of the same UUID will be deduplicated. It is not sufficient to have only a uniqueentity_id. Each event will need a UUID to avoid deduplication.
{    "account_id": "your_account_id",    "visitors":     [        {            "visitor_id": "test_user",            "attributes": [],            "snapshots": [              {               "decisions": [],               "events": [                 {                    "entity_id": "1260528912",                    "key": "test_event",                    "timestamp": 1540996187279,                    "uuid": "12a25c92-7edd1-1c30-21a8-aa4c850671e4",                    "revenue": 10000                 }               ]            }         ]       }     ],     "anonymize_ip": true,     "client_name": "Optimizely/event-api-demo",     "client_version": "1.0.0",     "enrich_decisions": true}

See theEvent API reference for required and optional fields.

Send data object asPOST call

After you build the JSON data object, send it to the following Event API endpoint
as aPOST call:<https://logx.optimizely.com/v1/events>.

There is no Authorization token requirement to use the API. The following is a sample cURL request.

After the API has received your complete call, it queues your JSON file for processing and returns a response with the status code204.

🚧

Important

The response does not indicate that your JSON has been validated. Consultthe Event API reference for more guidance.

curl -X POST  -H "Content-Type: application/json" -d  "https://logx.optimizely.com/v1/events"  {      "account_id": "your_account_id",      "visitors":       [          {              "visitor_id": "test_user",              "attributes": [],              "snapshots": [                {                 "decisions": [],                 "events": [                   {                      "entity_id": "1260528912",                      "key": "test_event",                      "timestamp": 1540996187279,                      "revenue": 10000,                      "uuid": "12a25c92-7edd1-1c30-21a8-aa4c850671e4"                   }                 ]              }           ]         }       ],       "anonymize_ip": true,       "client_name": "Optimizely/event-api-demo",       "client_version": "1.0.0",       "enrich_decisions": true  }
📘

Note

See theActivate users section for more information about theclient_name,client_version, andenrich_decisions fields shown in the preceding code sample.

Verify results

The data is reflected on theOptimizely Experiment Results page within a few minutes. To debug common issues, seeTroubleshoot the Event API.

Updated 2 months ago



[8]ページ先頭

©2009-2025 Movatter.jp