Skip to main content

Activating or exporting an audience

import decentriq_platform as dq

# establish connection
advertiser_email = "@@ YOUR EMAIL HERE @@"
advertiser_api_token = "@@ YOUR TOKEN HERE @@"
client = dq.create_client(advertiser_email, advertiser_api_token)
enclave_specs = dq.enclave_specifications.latest()
Setup Script

If you want to test this functionality and don't have a clean room already set up, you can use this script to create an appropriate environment to test the rest of this guide with.

import decentriq_platform as dq
from decentriq_platform.legacy.types import MatchingId

# establish connection
advertiser_email = "@@ YOUR EMAIL HERE @@"
advertiser_api_token = "@@ YOUR TOKEN HERE @@"
publisher_email = "@@ EMAIL OF PUBLISHER PARTICIPANT @@"
publisher_api_token = "@@ PUBLISHER TOKEN HERE @@"
advertiser_client = dq.create_client(advertiser_email, advertiser_api_token)
auth, _ = advertiser_client.create_auth_using_decentriq_pki(enclave_specs)
advertiser_session = advertiser_client.create_session(auth, enclave_specs)

# create new Media DCR
builder = dq.media.MediaDcrBuilder(client=advertiser_client)
dcr_definition = builder.\
with_name("My DCR").\
with_insights().\
with_lookalike().\
with_retargeting().\
with_matching_id_format(MatchingId.STRING).\
with_publisher_emails(publisher_email).\
with_advertiser_emails(advertiser_email).\
build()
media_dcr = advertiser_client.publish_media_dcr(dcr_definition)
dcr_id = media_dcr.id

# upload and publish data
key = dq.Key()
with open("/path/to/advertiser_data.csv", "rb") as file:
dataset_id = advertiser_client.upload_dataset(file, key, "advertiser.csv")
advertiser_session.publish_dataset(dcr_id, dataset_id, "audiences", key)

publisher_client = dq.create_client(publisher_email, publisher_api_token)
builder = dq.data_lab.DataLabBuilder(publisher_client)
builder.with_name("tutorial-data-lab")
builder.with_matching_id_format(dq.types.MatchingIdFormat.STRING)
builder.with_embeddings(50)
builder.with_demographics()
builder.with_segments()

data_lab = builder.build()

file_encryption_key = dq.Key()

data_lab.provision_local_datasets(
file_encryption_key,
"/path/to/matching_data.csv",
"/path/to/segments_data.csv",
demographics_data_path="/path/to/demographics_data.csv",
embeddings_data_path="/path/to/embeddings_data.csv",
)
data_lab.run()
validation_report = data_lab.get_validation_report()
statistics_report = data_lab.get_statistics_report()
data_lab.provision_to_media_insights_data_room(dcr_id)

# download activated audiences
activate_audience_list = [
dq.media.Audience(
audience_type="shoes",
activation_type=dq.media.ActivationType.RETARGET,
is_published=True,
),
]
media_dcr.activate_audience(
audiences=activate_audience_list
)

Styles of Activation

There are 2 main ways that data can be activated for use in an ad campaign. Both methods are initiated by the advertiser or agency.

  1. The data can either be made available to the publisher, allowing them to create a custom audience or custom segment that will appear in bid requests (often as a deal ID).
  2. the data can be downloaded by the advertiser or pushed via a connector to one of the advertiers vendors or partners. In this case the bidding will happen on a Publisher Provided ID (PPID) or other ID in the bid request.

Make available to Publisher

Coming soon

Download by Advertiser

Coming soon