Profiles

Retrieving profile objects

class ProfileMixin

This class defines all functions related to BlueConic profiles.

class ProfileExpandOptions(value)

This enumeration defines all profile expand options.

SEGMENTS

Expand segment data.

TIMELINE

Expand timeline data.

get_profile(profile_id, properties=None, include_timeline_events=False, timeline_events_filter=None, expand=None, pseudonymize_pii=False)

Gets the profile with the profile ID and returns it as a BlueConic profile.

Parameters
  • profile_id (str) – ID of the profile to return

  • properties ([str], optional) – The profile properties to return with the profile. Leave empty for all the profile properties. Defaults to None.

  • include_timeline_events (bool. Defaults to False.) – Add timeline events to profile

  • timeline_events_filter (TimelineEventsFilter, optional) – Timeline filters to limit the returned timeline events. See filtering timeline events for details.

  • expand (Sequence[ProfileExpandOptions], optional) – The objects to include with the retrieved profiles.

  • pseudonymize_pii (bool. Defaults to False.) – Pseudonymize_pii profile properties that are PII

Raises

HTTPError: Request fails

Returns

A profile with the requested properties

Return type

Profile

Usage:
>>> import blueconic
>>> bc = blueconic.Client()
>>> profile = bc.get_profile('example_profile_id', include_timeline_events=True)
>>> profile.id
Example Profile id
get_profiles(segment_id='allvisitors', start=None, count=1000, properties=None, progress_bar=True, required_properties=None, filters=None, include_timeline_events=False, timeline_events_filter=None, stage_id=None, expand=None, pseudonymize_pii=False)

Gets all profiles and returns them in a generator with all BlueConic profiles.

Parameters
  • segment_id (str) – Profiles are retrieved from the segment with this ID. If not specified the ‘allvisitors” segment is used

  • start (int, optional) – The profile to start from. Defaults to 0. Deprecated, doesn’t work anymore in R89.

  • count (int, optional) – The number of profiles to retrieve. To get all profiles in a segment, use count=0. Defaults to 1000.

  • properties ([str], optional) – The profile properties that should be retrieved. Leave empty to retrieve all profile properties. Defaults to None.

  • progress_bar (bool, optional) – Enables the view of the progress bar, which shows the progress of the profile retrieval. Defaults to True.

  • required_properties ([str], optional) – Profile properties that should be filled. Defaults to None.

  • filters (Union[FilterConfig, Sequence[FilterConfig]], optional) – Property filters to limit the returned profiles. See filtering profiles for details.

  • include_timeline_events (bool. Defaults to False.) – Add timeline events to profile

  • timeline_events_filter (TimelineEventsFilter, optional) – Timeline filters to limit the returned timeline events. See filtering timeline events for details.

  • stage_id (str, optional) – The stage id to filter on a stage of a lifecycle

  • expand (Sequence[ProfileExpandOptions], optional) – The objects to include with the retrieved profiles.

  • pseudonymize_pii (bool. Defaults to False.) – Pseudonymize_pii profile properties that are PII

Raises

ValueError – If count or start is lower than 0

Returns

Iterator with Profiles

Return type

Iterator[Profile]

Usage:
>>> import blueconic
>>> bc = blueconic.Client()
>>> segment_id = bc.get_blueconic_parameter_value("My segment","segment")
>>> profiles = bc.get_profiles(segment_id, count=10000)
>>> with bc.get_profile_bulkhandler() as bh:
>>>     for profile in profiles:
>>>         print(profile.id)
>>>         next_best_product_for_this_profile = calculate_next_best_product_for_this_profile()
>>>         profile.add_value('next_best_product', next_best_product_for_this_profile)
>>>         bh.write(profile)

Using profile objects

class Profile
__init__(profile_id=None, properties=None, segments=None, permission_level=None, privacy_legislation=None, consented_objectives=None, refused_objectives=None, timeline_events=None)

This class represents a BlueConic profile.

Parameters
  • profile_id (str) – The ID of the profile

  • properties ([str]) – The profile properties of this profile

  • segments (Sequence[str], optional) – The segments this profile occurs in at this moment. Defaults to None.

  • permission_level (str, optional) – The permission level of this profile. Defaults to None.

  • privacy_legislation (str, optional) – The privacy legislation of this profile. Defaults to None.

  • consented_objectives (Sequence[str], optional) – The objectives this profile consented to. Defaults to None.

  • refused_objectives (Sequence[str], optional,) – The objectives this profile refused. Defaults to None.

  • timeline_events (Iterable[TimelineEvent]) – The timeline events of this profile. Defaults to None.

add_timeline_event(timeline_event)

Add a single timeline event to this profile. Deprecated in favor of ProfileOperation.add_timeline_operation().

Parameters

timeline_event (TimelineEvent) – The timeline event to be added to the profile.

add_timeline_events(*timeline_events)

Add a list of timeline event to this profile.

Parameters

timeline_events ([TimelineEvent]) – The timeline events to be added to the profile.

add_value(property_id, property_value)

Adds one value to the property. Keeps existing values intact.

Parameters
get_value(property_id)

Gets the first value of a property.

Parameters

property_id (str) – The ID of the property to retrieve the value from

Raises

KeyError – If the ID does not refer to an existing property

Returns

The first value of the property

Return type

str

get_values(property_id)

Gets all values of a property.

Parameters

property_id (str) – The ID of the property to retrieve the values from

Raises

KeyError – If the ID does not refer to an existing property

Returns

All the values of the property

Return type

[str]

set_value(property_id, property_value, set_if_empty=False)

Sets one value for this property. Removes all values that were already present.

Parameters
  • property_id (str) – The ID of the property

  • property_value (int or str or bool or float or datetime.datetime) – The value to set. All values are cast to a string

  • set_if_empty (bool, optional) – When set to False, the existing value will always be replaced with the new value. Set this parameter to True to set the new value only when there was no value yet present in the property. Defaults to False.

Raises

KeyError – If the ID does not refer to an existing property

set_values(property_id, property_values, set_if_empty=False)

Sets multiple values for this property. Remove all values that were already present.

Parameters
  • property_id (str) – The ID of the property

  • property_values ([int or str or bool or float or datetime.datetime]) – A list of values. All values are cast to a string

  • set_if_empty (bool) – When set to False, the existing values will always be replaced with the new values. Set this parameter to True to set the new values only when there were no values yet present in the property. Defaults to False.

property consented_objectives

Returns the consented objectives of this profile.

property id

Returns the ID of this profile.

property permission_level

Returns the permission level of this profile.

property privacy_legislation

Returns the privacy legislation of this profile.

property properties

Returns the properties of this object.

property property_ids

Returns the property IDs of this object.

property refused_objectives

Returns the refused objectives of this profile.

property segments

Returns the segment IDs of this profile.

property timeline_events

Returns the timeline events of this profile.