10.1.12 Automate Flexible Targeting setups for Media Buying with the new Merge Targeting Flow Action.
Overview: Why Use the Merge Targeting Action?
ADvendio provides the Merge Targeting Apex Action to enhance automation capabilities within Salesforce Flows. This action allows you to programmatically combine two separate ADvendio targeting JSON strings into a single, unified JSON string. It intelligently merges the criteria, removes duplicates, and ensures the resulting targeting is valid for a specific ADvendio connection.
This is particularly powerful for Media Buying automation. For instance, you can take the base targeting defined on a Campaign Item and merge it with specific criteria stored in a Targeting Set (like a predefined location list or audience segment) to automatically create the final, combined targeting for a Buying Item.
Key Features
Combines Targeting: Merges two valid ADvendio targeting JSON strings into one.
Handles Duplicates: Automatically removes duplicate targeting entries during the merge.
Connection Validation: Crucially, it validates that the targeting criteria in both input strings belong to the same ADvendio Connection, preventing invalid combinations.
Structured Merging: Merges standard categories (Geography, Device, Inventory, etc.) by combining unique IDs. Merges Key Values and Audience Segments based on the logic used in Flexible Targeting Sets (typically creating combined groups linked by AND).
Invocable: Designed for easy use as an Action within Salesforce Flows.
How to Use the 'Merge Targeting' Action in a Flow
Add Apex Action: In your Flow, add an 'Action' element and search for "Merge Targeting".
Configure Inputs: Set the following input parameters:
jsonString1 (Text, Required): The first targeting JSON string (e.g., from a Campaign Item's
AdServerTargeting__cfield).jsonString2 (Text, Required): The second targeting JSON string (e.g., from a Targeting Set's definition field).
targetingType (Text, Optional): Specifies the type or field the JSON strings represent.
Enter
adservertargeting(case-insensitive) or leave blank/null if merging standard targeting from fields likeAdServerTargeting__c. This is the primary supported type currently.For AdvancedSettings the expected value is
advancedsettings. This is used for specific targetings like Floodlight Activities or URLs and APPs for Google DV360For PostalCodes the expected value is
postalcodes. This is required if you want to merge Postal Code Lists from the AdPostalCodes field for Facebook or Pinterest.
Handle Outputs: The action returns the following outputs. You can just use these in the default Salesforce outputs OR assign them to specific variables:
result (Text): The merged targeting JSON string. Store this in a Text variable.
status (Text): Indicates the outcome - "SUCCESS" or "ERROR". Store this in a Text variable.
message (Text): Provides details about the success or error (e.g., "Merge successful", "Error: Targeting strings belong to different connections"). Store this in a Text variable.
Process Results: Use a 'Decision' element after the action to check the
statusoutput variable.If "SUCCESS", proceed with your Flow logic using the merged JSON stored in the
resultvariable (e.g., update a Buying Item's targeting field).If "ERROR", handle the error appropriately (e.g., log the
message, notify an admin).
Use Cases - How to use the targeting merge
This new method combined with capabilities such as Targeting Sets, Campaign Item Targeting will give you a whole new way to simply automate your end to end Media Buying processes.
A few examples on how to effectively use this:
Use Targeting Sets for defined Targeting Criteria in easy to select collections; Allow users on Campaign Items to choose them and via flows and automation copy down the targeting criteria into individual Buying Items.
Sets can be based on: Region or Postal Code Lists, Selected Supply Partners or Exchanges, Brand Safety configurations, Targeted Devices and formats
Save default Targeting configurations, which should always be used for an integrated platform and should be combined with criteria a user manually select on a Campaign Item.
(simplified)Flow Example: Applying Targeting Set Criteria to a Buying Item
Scenario: You want to automatically create Buying Items where the targeting is a combination of the general targeting set on the parent Campaign Item and specific criteria (e.g., a location list) stored in a related Targeting Set record.
Flow Steps (Simplified):
Trigger: Start the Flow when needed (e.g., when a Buying Item is created without targeting, or based on updates to the Campaign Item or a related record indicating a Targeting Set).
Get Records: Retrieve the necessary records:
The source Campaign Item (to get its
AdServerTargeting__c).The relevant Targeting Set record (to get its
AdServerTargeting__c).The target Buying Item record (to update).
Call 'Merge Targeting' Action:
jsonString1:{![CampaignItem].AdServerTargeting__c}jsonString2:{![TargetingSet].AdServerTargeting__c}targetingType:adservertargeting(or leave blank)Store outputs in variables (e.g.,
mergedJsonResult,mergeStatus,mergeMessage).
Decision (Check Status): Verify if
mergeStatusequals "SUCCESS".If Success - Update Buying Item: Use an 'Update Records' element to set the target Buying Item's
SelectedTargeting__cfield to the value stored in themergedJsonResultvariable.If Error - Handle Error: Log the
mergeMessage, send a notification, etc.
Automation Tip: Using multiple Targeting Sets or other Source objects for technical targeting strings, requires a loop to go through all objects and merge the Targeting step by step.
Important Considerations & Limitations (As of Release 2.176)
Connection Validation: The action will fail (return "ERROR" status) if the Connection IDs found within the two input JSON strings belong to different ADvendio Connection records.
Empty Inputs: The action will fail if either
jsonString1orjsonString2is empty or null.Merge Logic (Key Values/Audience Segments): The current merge logic for these complex types follows the Flexible Targeting Sets approach, generally combining groups with AND logic. Platform-specific rules (e.g., Freewheel's 3-group limit, Facebook/Pinterest's flat list requirement) are not currently enforced by this merge action and may require handling in separate logic or future enhancements. Merging may result in structures not fully supported by all platform integrations.
Merge Logic (Standard Categories): Should merge unique IDs correctly. Issues with duplicate Connection IDs appearing in the output for standard categories might occur and are being addressed in follow-up improvements.
Supported
targetingType:Currently only the ADvendio Standard Targeting (Field: AdserverTargeting__c, SelectedTargeting__c) from Objects like Targeting Set, Campaign Item or Buying Item is supported in the merge.
DV360 Floodlights, App IDs and URL lists (Field: AdvancedSettings__c) will be included in Release 2.178
Freewheel Yield Optimization (Field: AdvancedSettings__c) is not yet supported by the merge targeting action
Google AdManager Creative Targeting and Xandr Splits (Field: SubTargeting__c) is not yet supported by the merge targeting action
Best Practices
Validate Inputs: Where possible in your Flow, check if input strings are not empty before calling the action.
Error Handling: Always check the
statusoutput and handle potential errors gracefully.Test Thoroughly: Test your Flow with various targeting combinations to ensure the merge behaves as expected for your use cases.
Monitor: Keep an eye on Flow execution logs for any unexpected errors or results from the merge action.