8.1.4 Clean your Geo Targeting Data
It can be very inconvenient if all Geo AdServer Ids are in the system. Especially if you want to select a geo-targeting. Therefore you can delete the AdServer Ids that you don't need within Advendio using the developer console. Remember that the following code can differ depending on which country do you want to keep.
1. Delete Unwanted AdServer Ids
First, you delete all countries that you don't need using the following code:
Code
delete [SELECT Id FROM ADvendio__Adserver_Id__c WHERE RecordtypeID = 'yourdfprecordtypeid' AND ADvendio__Type__c = 'Country' AND (Name != 'Germany' and Name != 'Switzerland' and Name != 'Austria') LIMIT 10000];
In this example, Germany, Switzerland and Austria will not be deleted.
Then you have to delete the rest. Some queries you have to run multiple times because of the structure of their parent AdServer Ids. The parent AdServer ID must be empty:
Code
delete [SELECT Id FROM ADvendio__Adserver_Id__c WHERE RecordtypeID = 'yourdfprecordtypeid' AND ADvendio__Type__c = 'Region' AND ADvendio__Parent_AdServer_ID__c = '' LIMIT 10000];
delete [SELECT Id FROM ADvendio__Adserver_Id__c WHERE RecordtypeID = 'yourdfprecordtypeid' AND ADvendio__Type__c = 'State' AND ADvendio__Parent_AdServer_ID__c = '' LIMIT 10000];
delete [SELECT Id FROM ADvendio__Adserver_Id__c WHERE RecordtypeID = 'yourdfprecordtypeid' AND ADvendio__Type__c = 'Municipality' AND ADvendio__Parent_AdServer_ID__c = '' LIMIT 10000];
delete [SELECT Id FROM ADvendio__Adserver_Id__c WHERE RecordtypeID = 'yourdfprecordtypeid' AND ADvendio__Type__c = 'Governorate' AND ADvendio__Parent_AdServer_ID__c = '' LIMIT 10000];
delete [SELECT Id FROM ADvendio__Adserver_Id__c WHERE RecordtypeID = 'yourdfprecordtypeid' AND ADvendio__Type__c = 'DMA Region' AND ADvendio__Parent_AdServer_ID__c = '' LIMIT 10000];
delete [SELECT Id FROM ADvendio__Adserver_Id__c WHERE RecordtypeID = 'yourdfprecordtypeid' AND ADvendio__Type__c = 'Department' AND ADvendio__Parent_AdServer_ID__c = '' LIMIT 10000];
delete [SELECT Id FROM ADvendio__Adserver_Id__c WHERE RecordtypeID = 'yourdfprecordtypeid' AND ADvendio__Type__c = 'Airport' AND ADvendio__Parent_AdServer_ID__c = '' LIMIT 10000];
delete [SELECT Id FROM ADvendio__Adserver_Id__c WHERE RecordtypeID = 'yourdfprecordtypeid' AND ADvendio__Type__c = 'Province' AND ADvendio__Parent_AdServer_ID__c = '' LIMIT 10000];
delete [SELECT Id FROM ADvendio__Adserver_Id__c WHERE RecordtypeID = 'yourdfprecordtypeid' AND ADvendio__Type__c = 'Autonomous Community' AND ADvendio__Parent_AdServer_ID__c = '' LIMIT 10000];
delete [SELECT Id FROM ADvendio__Adserver_Id__c WHERE RecordtypeID = 'yourdfprecordtypeid' AND ADvendio__Type__c = 'County' AND ADvendio__Parent_AdServer_ID__c = '' LIMIT 10000];
delete [SELECT Id FROM ADvendio__Adserver_Id__c WHERE RecordtypeID = 'yourdfprecordtypeid' AND ADvendio__Type__c = 'Territory' AND ADvendio__Parent_AdServer_ID__c = '' LIMIT 10000];
delete [SELECT Id FROM ADvendio__Adserver_Id__c WHERE RecordtypeID = 'yourdfprecordtypeid' AND ADvendio__Type__c = 'Neighborhood' AND ADvendio__Parent_AdServer_ID__c = '' LIMIT 10000];
If you did this correctly, the cities are the last AdServerIDs to delete:
Code
delete [SELECT Id FROM ADvendio__Adserver_Id__c WHERE RecordtypeID = 'yourdfprecordtypeid' AND ADvendio__Type__c = 'City' AND ADvendio__Parent_AdServer_ID__c = '' LIMIT 100000];
2. Import only needed Geo Targeting AdServer IDs
The second option is to perform the Geo Import not from AdServer Login, but from an csv file - See the example for the European DACH region below. Remember that the ids must be changed to YOUR system values.
- Download the file or use your own data
- Make a selection of which data you need - delete data which you don't use
- Import via Dataloader or equal into the Object AdServer ID. Make sure that the following fields are mapped:
- Record Type: "Your Adserver"
- AdServer ID Name = Description or other
- AdServer Login: Enter the reference to your AdServer Login
- AdServer ID = Your Adserver's ID
- AdServer Name = Description
- Type:
- Country
- Region
- City
- DMA
- Postal Code
- Category: Geography
- Active: TRUE - if you using this feature : 3.1.8 Active and inactive inventory items
- Parent Id: Enter the reference to the parent:
- Country - no parent
- State / Region - Country
- City - Region
- Postal Code - Country
- DMA - Country