This article helps you:
Use the Profile API to deploy your recommendations
Understand and analyze the results
Once you've created a new recommendation, you'll need to integrate it into your personalization campaigns. This article describes the process, using the Profile API.
The primary destination for deploying a recommendation is Amplitude’s Profile API. This is a real-time API, which you can call by user ID or device ID, and in less than a second, Amplitude will return an array of information about the user.
You can give a recommendation access to the Profile API by navigating to the Syncs tab and selecting the Profile API as a destination for the recommendation.
The Profile API is a REST endpoint, queryable by user ID or device ID and serving JSON responses on a per user basis:
https://profile-api.amplitude.com/v1/userprofile |
To authenticate to use the API, use the Secret Key from the project settings in Amplitude (Settings → Projects → [select project] → General).
Query parameters are set to specify the user ID and the recommendation. Results are returned as a JSON response body.
The following example request returns the results for a specific user and recommendation. The ID for a specific recommendation is found in the Details section of a recommendation page.
curl -H "Authorization: Api-Key Secret-Key" 'https://profile-api.amplitude.com/v1/userprofile?user_id=myuser&rec_id=s234ssg' |
A sample response for this query is:
{ |
"userData": { |
`"recommendations": |
[` |
{ |
`"rec_id": |
"s234ssg",` |
`"is_control": |
true,` |
`"items": |
["investing-101", "mortgage-rates-primer", "retirement-goals", |
"what-is-a-cd", "setting-up-direct-deposit"],` |
`"recommendation_source": |
"recommendations_model_v2",` |
"last_updated":1.61419226E9 |
}, |
... |
], |
"user_id":"myuser", |
"device_id":"bef34a71-62cd-5b2e-af2f-58cd2eabb4d9", |
"amp_props":null |
} |
} |
The response contains three key pieces of information:
rec_id
: the unique identifier of the recommendationIs_control
: a true/false result, indicating whether the user is in the control or treatment for recommendationitems
: an array of strings. The items are ordered by predicted likelihood to optimize the outcome, with the first having the highest probabilityThe API can also be used to retrieve user properties, predictions, and cohort membership. The following example sends a request to retrieve a recommendation, all user properties, a prediction and cohort memberships:
curl -H "Authorization: Api-Key Secret-Key" 'https://profile-api.amplitude.com/v1/userprofile?user_id=myuser&rec_id=s234ssg&get_amp_props=true&prediction_id=t456tth&get_cohorts=true' |
A sample response for this query is:
{ |
"userData": { |
"user_id": "myuser", |
"device_id":"bef34a71-62cd-5b2e-af2f-58cd2eabb4d9", |
`"amp_props": |
{` |
`"country": |
"United States",` |
"city":"Springfield", |
"first_used":"2019-04-30", |
"language":"English", |
"carrier":"Verizon", |
"last_used":"2021-02-25" |
`"plan_type": |
"starter",` |
`"device":"samsung |
samsung SM-N976V",` |
`"os": |
"android 30",` |
"app_version":"6.1.0", |
`"gp:membership_points": |
"1752",` |
`"gp:initial_utm_campaign": |
"abcd",` |
"gp:email":"user@example.com", |
}, |
`"recommendations": |
[` |
{ |
`"rec_id": |
"s234ssg",` |
`"is_control": |
true,` |
`"items": |
["investing-101", "mortgage-rates-primer", "retirement-goals", |
"what-is-a-cd", "setting-up-direct-deposit"],` |
`"is_control": |
false,` |
`"recommendation_source": |
"recommendations_model_v2",` |
"last_updated":1.61419226E9 |
}, |
... |
], |
`"predictions": |
[` |
{ |
`"name": |
"Likelihood to Convert",` |
`"percentile": |
97.5,` |
`"pred_id": |
"t456tth",` |
`"probability": |
0.734` |
}, |
... |
], |
`"cohort_memberships": |
[` |
"u567uui", |
... |
] |
} |
} |
The Profile API makes embedding recommendations into a customer’s digital workflows highly extensible. To do so, follow these steps:
is_control
:
false
, then use items
in the recommended payload.true
, then default to the baseline product experience. items
is populated with a random selection of items; this may or may not be a good choice for a baseline.recommendations
block is null
, or the API returns an error, default to the baseline product experience. This means either the user is not yet known to Amplitude, or there isn’t enough user history to provide recommendations for this user.Once the Profile API is deployed into a customer’s app, website, or email channels, Amplitude Audiences will be able to measure performance of the recommendation. It does this by logging an Amplitude event ( [Recs] Recommendation Event
) every time the Profile API is called for that specific recommendation.
This will not count against your event volume
To view the performance of your recommendation, open the recommendation you’re interested in and click on the Performance tab.
You will see summary stats from a funnel conversion chart:
Amplitude defines "significance" as the value of 1 - *p*
, where p is determined by a two-sided t test. (In some cases, certain previously-saved charts may still display chance to outperform, in order to maintain the consistency of past results.)
This funnel compares two segments: a control segment and a treatment segment. For the control segment, recommendations.recommendation_control = True
. For the treatment segment, recommendations.recommendation_control = False
.
The default funnel consists of two steps, the exposure event and outcome event. You can update this manually if you need to. It will show you a comparison of the two segments over time.
You can see whether the difference between the Control and Treatment segments is statistically significant by checking the value in the Significance column.
With this information, you should be able to quantify the concrete impact each recommendation has made to your bottom line.
Thanks for your feedback!
May 7th, 2024
Need help? Contact Support
Visit Amplitude.com
Have a look at the Amplitude Blog
Learn more at Amplitude Academy
© 2024 Amplitude, Inc. All rights reserved. Amplitude is a registered trademark of Amplitude, Inc.