AdAudiences
Retrieve details for some or all Tailored Audiences associated with the current account.
View Specific Information
Select
Only the Id filter is supported.
SELECT * FROM AdAudiences WHERE Id = 'TXR1'
Insert
This table supports simple Insert and batch Insert operations.
Simple Insert:
INSERT INTO [AdAudiences] (name) VALUES ('test')
Batch Insert:
Batch inserts are used to generate a new audience based on existing audiences and by setting a couple of conditions on them.
For example: To create a new audience based on the most active users of X1 AND (X2 or X3) audience the structure would be like this:
INSERT INTO a#TEMP (CustomAudienceId, frequency, frequencyComparator, lookbackWindow, negate) VALUES ('TYIF', 1, 'NUM_GT', 30, true)
INSERT INTO b#TEMP (CustomAudienceId, lookbackWindow) VALUES ('TXR1', 30)
INSERT INTO c#TEMP (CustomAudienceId, frequency, frequencyComparator, lookbackWindow, negate) VALUES ('TYFO', 1, 'NUM_GT', 30, true)
INSERT INTO AdAudiences#TEMP (audienceType, name, segments) VALUES ('FLEXIBLE', 'Test1', 'a#TEMP AND (b#TEMP OR c#TEMP)')
INSERT INTO [AdAudiences] (audienceType, name, segments) SELECT audienceType, name, segments FROM [AdAudiences#TEMP]
Make sure to set the required columns on initial temp tables, for example a#TEMP, which are: CustomAudienceId and LookbackWindow.
Values that are set in these temp table will be used by AdAudiences#TEMP in the Segments column, which will be used as a criteria, combined with AND/OR logical operators.
Update
This table supports simple and batch Update operations.Simple Update:
UPDATE [AdAudiences] SET Name = 'testModified' WHERE Name = 'test'
Batch Update:
Batch updates are used to modify an existing audience by setting a couple of new conditions on it.
For example: To modify an audience based on the most active users of X1 AND (X2 or X3) audience the structure would be like this:
INSERT INTO a#TEMP (CustomAudienceId, frequency, frequencyComparator, lookbackWindow, negate) VALUES ('TYIF', 1, 'NUM_GT', 30, true)
INSERT INTO b#TEMP (CustomAudienceId, lookbackWindow) VALUES ('TXR1', 30)
INSERT INTO c#TEMP (CustomAudienceId, frequency, frequencyComparator, lookbackWindow, negate) VALUES ('TYFO', 1, 'NUM_GT', 30, true)
INSERT INTO AdAudiences#TEMP (audienceType, name, segments) VALUES ('FLEXIBLE', 'Test1', 'a#TEMP AND (b#TEMP OR c#TEMP)')
UPDATE [AdAudiences] (audienceType, name, segments) SELECT audienceType, name, segments FROM [AdAudiences#TEMP]
Delete
This table supports simple and batch Delete operations.Simple Delete:
DELETE FROM [AdAudiences] WHERE Name = 'test'
Batch Delete:
INSERT INTO a#TEMP (CustomAudienceId, frequency, frequencyComparator, lookbackWindow, negate) VALUES ('TYIF', 1, 'NUM_GT', 30, true)
INSERT INTO b#TEMP (CustomAudienceId, lookbackWindow) VALUES ('TXR1', 30)
INSERT INTO c#TEMP (CustomAudienceId, frequency, frequencyComparator, lookbackWindow, negate) VALUES ('TYFO', 1, 'NUM_GT', 30, true)
INSERT INTO AdAudiences#TEMP (audienceType, name, segments) VALUES ('FLEXIBLE', 'Test1', 'a#TEMP AND (b#TEMP OR c#TEMP)')
DELETE FROM [AdAudiences] WHERE EXISTS SELECT audienceType, name, segments FROM [AdAudiences#TEMP]
Columns
Name | Type | ReadOnly | Description |
Id [KEY] | String | True |
The unique identifier of the ad tailored audience. |
AccountId | String | False |
Id of the advertising account to work with. |
OwnerAccountId | String | True |
The unique identifier of the owner account. |
Name | String | False |
The name of the tailored audience. |
AudienceSize | Integer | True |
The size of the tailored audience. |
AudienceType | String | True |
The type of the tailored audience. |
CreatedAt | Datetime | True |
The time of the creation of this audience. |
UpdatedAt | Datetime | True |
The time of the last change of the properties of this audience. |
PartnerSource | String | True |
The partner source of this tailored audience. |
PermissionLevel | String | True |
The permission level of this tailored audience. |
ReasonsNotTargetable | String | True |
The reasons why this audience is not targetable, if it is not targetable. |
TargetableTypes | String | True |
Targetable types of the audience. |
Targetable | Boolean | True |
Shows if the audience is targetable or not. |
Deleted | Boolean | True |
Whether the audience is deleted. |
Segments | String | True |
Useful only in Batch Insert, Update and Delete operations. |
Pseudo-Columns
Pseudo column fields are used in the WHERE clause of SELECT statements and offer a more granular control over the tuples that are returned from the data source.
Name | Type | Description |
IncludeDeleted | String |
Boolean used for including or not the deleted accounts. The default value is false. |