Edit in GitHubLog an issue

Get Attributes

Description#

get_attributes() is used to fetch experimentation and personalized experiences from Target and extract attribute values.

Method#

Copied to your clipboard
target_client_instance.get_attributes(mbox_names, options)

Parameters#

NameTypeRequiredDefaultDescription
mbox_nameslist[str]YesNoneA list of mbox names
optionsdictNoNoneThe same options as used for Get Offers​

AttributesProvider#

The AttributesProvider returned by target_client.get_attributes() has the following methods:

MethodReturn TypeDescription
get_value(mbox_name, key)anyReturns the value for a specified mbox name and attribute key
as_object(mbox_name)dictReturns a simple json object with key value pairs
get_response()TargetDeliveryResponseReturns the response object normally returned by get_offers

Example#

Copied to your clipboard
1def client_ready_callback():
2 context = Context(channel=ChannelType.WEB)
3 mboxes = [MboxRequest(name="a1-serverside-ab", index=1)]
4 execute = ExecuteRequest(mboxes=mboxes)
5 delivery_request = DeliveryRequest(context=context, execute=execute)
6
7 get_attributes_options = {
8 "request": delivery_request
9 }
10
11 attributes_provider = target_client.get_attributes(["demo-engineering-flags"], get_attributes_options)
12 # returns just the value of searchProviderId from the demo-engineering-flags mbox offer
13 search_provider_id = attributes_provider.get_value("demo-engineering-flags", "searchProviderId")
14
15 # returns a simple dict object representing the demo-engineering-flags mbox offer
16 engineering_flags = attributes_provider.as_object("demo-engineering-flags")
17 """ the value of engineeringFlags looks like this
18 {
19 "cdnHostname": "cdn.cloud.corp.net",
20 "searchProviderId": 143,
21 "hasLegacyAccess": false
22 }
23 """
24
25 asset_url = "http://{}/path/to/asset".format(engineering_flags.get("cdnHostname"))
26
27
28client_options = {
29 "client": "acmeclient",
30 "organization_id": "1234567890@AdobeOrg",
31 "events": {
32 "client_ready": client_ready_callback
33 }
34}
35target_client = TargetClient.create(client_options)
Was this helpful?
  • Privacy
  • Terms of Use
  • Do not sell my personal information
  • AdChoices
Copyright © 2022 Adobe. All rights reserved.