Demo for server-side integration with Amp.ai
- Linux or Mac system with at least 4GB RAM
- Docker
- Golang 1.11
- Create a demo project in the Amp.ai console at https://amp.ai.
- Run Amp-agent locally in a terminal using:
./run-amp-agent.sh <customer_key>
. The customerKey will be provided to you by email. - After a few minutes, start the web server:
go run web_server/web_server.go --key=<project_key>
. The projectKey can be found under theINFO
section of the console. - Start the reporting server:
go run reporting_server/reporting_server.go
. - Open up the Chrome browser and navigate to
http://localhost:8080/
. You'll see a web page asking for a donation for saving the Bay area tree octopus. On the page you'll see a slogan encouraging you to donate. This is the default or control variant in the experiment. - On the web page, enter a donation amount and click "Donate". You'll see the Outcome request in the reporting server logs. The Context and Decision events can be viewed in the web server logs.
- If you refresh the page you'll see the same slogan as before, as the web server placed a cookie in your browser. Under the Chrome DeveloperTools "Application" Tab, click the cookies section to inspect the AmpToken. Refreshing the page ensures the same AmpToken is present, guaranteeing decision persistence for the duration of the session. This is useful as a user may return to the page after a while or refresh it, and the outcome event is stitched into the same session using the AmpToken.
- In the Amp.ai console, under "INFO", click "View" beside "Total Sessions" to sample sessions. Wait for a couple of minutes if no data is present and retry. Peek into a sample session to view the Context, Decision and Outcome events.
- Return to the main page of the console and create a metric "Donation" by clicking on the "+" button on the left panel. Select a suitable metric name and pick the Outcome event "UserOutcome". Choose to maximize existence of the Outcome event by setting 3 up arrows and the "Exists" tab. Thereafter, save the metric.
- Next, approve the decision point by clicking on "Decisions" (under the "INFO" section) and checking off the decision. If the decision point is not approved, only the control variant is served by the Amp-agent.
- Allocate traffic to the Amped group (or optimized group) by setting "Current Allocation" to 80%. The Amp.ai console tracks statistics for the Amped group of sessions versus the control group continuously.
- After a couple of minutes, head back to the browser and purge the AmpToken from the cookie. This is equivalent to loosing a handle to the session and starting a new one. Refresh the page again multiple times and purge the AmpToken each time. You should see a different variant each time, chosen randomly. This confirms that the demo setup is working.