Segments
Retrieving segment objects
- class SegmentMixin
This class defines all functions related to
BlueConic segments
.- get_segment(segment_id)
Gets the segment with the segment ID and returns it as a
BlueConic segment
.- Parameters:
segment_id (str) – The ID of the segment
- Raises:
HTTPError
: Request fails- Returns:
Segment
- Return type:
- Usage:
>>> import blueconic >>> bc = blueconic.Client() >>> segment_id = bc.get_blueconic_parameter_value("Customers segment","segment") >>> customers_segment = bc.get_segment(segment_id) >>> print(customers_segment.name) Customers
- get_segments(start=0, count=10000000)
Gets all segments and returns them in a generator with all
BlueConic segments
.- Parameters:
- Returns:
Iterator with Segment
- Return type:
Iterator[Segment]
- Usage:
>>> import blueconic >>> bc = blueconic.Client() >>> all_segments = bc.get_segments() >>> all_visitors_segment = None >>> for segment in all_segments: >>> if segment.name == 'All visitors': >>> all_visitors_segment = segment >>> break >>> print(all_visitors_segment.name) All visitors
Retrieve number of profiles in a segment
- class NumberOfProfilesMixin
This class defines all functions related to
BlueConic segments
.- get_nr_of_profiles(segment_id='allvisitors', extra_options=None, apply_objective_ids=False, stage_id=None, filters=None)
Gets the number of profiles in this segment.
- Parameters:
segment_id (str) – The ID of this segment
apply_objective_ids (bool, optional) – Enable options for objectives for privacy management and GDPR. Default is False.
stage_id (str, optional) – The stage id to filter on a stage of a lifecycle
filters (Union[FilterConfig, Sequence[FilterConfig]], optional) – Property filters to limit the profiles included in the count
- Returns:
The number of profiles in this segment
- Return type:
- Usage:
>>> import blueconic >>> bc = blueconic.Client() >>> print(bc.get_nr_of_profiles('example_segment_id')) 42
Using segment objects
- class Segment
- get_nr_of_profiles()
Gets the number of profiles in this segment.
- Returns:
The number of profiles in this segment
- Return type:
- get_profiles(start=None, count=1000, properties=None, group_properties=None, progress_bar=True, required_properties=None, filters=None, include_timeline_events=False, timeline_events_filter=None, stage_id=None, expand=None)
Gets all profiles and returns them in a generator with all
BlueConic profiles
.- Parameters:
start (int, optional) – The profile to start from. Defaults to 0. Deprecated.
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 properties which should be retrieved. Leave empty to retrieve all profile properties. Defaults to None.
group_properties ([str], optional) – The group properties that should be retrieved. Leave empty to retrieve all group properties. Defaults to None.
progress_bar (bool, optional) – Enable the view of the progress bar which shows the progress of the profiles 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.
- 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") >>> segment = bc.get_segment(segment_id) >>> print("First three profile IDs in segment '" + segment.name + "':") >>> for profile in segment.get_profiles(count=3): >>> print(profile.id) First three profile IDs in segment 'All Profiles': 9221b26e-740a-4360-9466-97428e77ac8d 60c5834b-63c4-42f9-a3be-c21814087e16 7717c868-f1fd-45e9-a53b-51210e6ec6c8
- property creation_date
- Returns:
The creation date of this object.
- Return type:
Optional[datetime]
- property creator_username
- Returns:
The username that created this object.
- Return type:
Optional[str]
- property description
- Returns:
Description of this object.
- Return type:
Optional[str]
- property id
- Returns:
ID of this object.
- Return type:
- property inverse_of
Returns the ‘inverse of’ of this segment.
- Usage:
>>> import blueconic >>> bc = blueconic.Client() >>> segment = bc.get_segment('6d1ed148-8a5d-4d83-b98f-e8410fa6b0b4') >>> segment.name 'Not "United States"' >>> segment.inverse_of '645359c0-70fd-414a-bef8-cb839d5490ea' >>> bc.get_segment(segment.inverse_of).name 'United States'
- property inversed_by
Returns the ‘inversed by’ of this segment.
- Usage:
>>> import blueconic >>> bc = blueconic.Client() >>> segment = bc.get_segment('6d1ed148-8a5d-4d83-b98f-e8410fa6b0b4') >>> segment.name 'United States' >>> inversed_by = bc.get_segment(segment.inversed_by) >>> inversed_by.name 'Not "United States"'
- property labels
- Returns:
The labels this object.
- Return type:
Optional[Sequence[str]
- property last_modified_date
- Returns:
The last modified date of this object.
- Return type:
Optional[datetime]
- property last_modified_username
- Returns:
The last modified username of this object.
- Return type:
Optional[str]
- property name
- Returns:
Name of this object.
- Return type:
Optional[str]