Configure Consent Tracking for Specific Accounts in Community Hub
If your association complies with various data protection and privacy regulations, you may need to ask only specific constituents to provide consent. This recipe serves as one example of how you might display a marketing consent alert only to residents in certain European countries, with a button to provide consent.
Recipe Prep
Keep these things in mind:
- You have gone through the steps to Enable Data Protection and Privacy
- You are aware of the Consent Tracking recipe and how it configures consent tracking for all constituents, whereas this recipe is for specific constituents
To make this recipe, you should understand:
- How to Create a Flow (external)
- How to Create a Card
Ingredients
You will mix these ingredients together to make this recipe:
Name | Type | Description |
---|---|---|
MarketingConsentProvided | Flow | In Community Hub, this flow is run when a logged in constituent clicks the Marketing Consent Provided button, which passes an SObject collection variable of accounts into the flow. The flow loops through this SObject collection variable—which, in this recipe, only contains one account record—and updates the value of marketing consent fields on the account record. |
CurrentAccountId | Query | Queries the account ID of the constituent currently logged into Community Hub. |
CurrentAccountId | Data Source | Passes the CurrentAccountId query to the Marketing Consent Provided button. |
Marketing Consent Provided | Button | In Community Hub, logged in constituents click this button to run the MarketingConsentProvided flow. |
Marketing Consent Required | Access Control | References a formula field on the logged in constituent's account record to determine if the Marketing Consent Alert card should display. |
Marketing Consent Alert | Card | In Community Hub, this card displays a message and the Marketing Consent Provided button to logged in constituents. |
Directions
Create Custom Consent Fields
Custom consent fields track whether constituents have consented to having their data used for marketing purposes.
Create the following custom fields on the Contact object:
Field Label Suggested API Name Field Type Description Consented to Marketing
ConsentedToMarketing
Checkbox
If true, the constituent has consented to having their data used for marketing purposes. Last Consented to Marketing Date
LastConsentedToMarketingDate
Date
The date the constituent either gave or did not give consent to having their data used for marketing purposes.
Create an Autolaunched Flow and Button to Run the Flow
- Using Cloud Flow Designer, create the MarketingConsentProvided flow:
Create SObject resources with the following values:
Resource Type Unique Name Input/Output Type Object Type Description SObject Collection Variable InputSObjects
Input Only
Account
The account records passed in as inputs from the Marketing Consent Provided button. SObject Variable CurrentAccount
Private
Account
The current iteration in the loop through the InputSObjects SObject collection variable. SObject Collection Variable AccountsToUpdate
Private
Account
The temporary SObject where the loop stores the updated marketing consent field values. Create a Formula resource with the following values:
Resource Type Unique Name Value Data Type Formula Description Formula Today
Date
TODAY()
Returns today's date. Create a Loop element named "Loop Thru InputSObjects" with the following values:
Loop through Loop Variable Description {!InputSObjects}
{!CurrentAccount}
Loops through the InputSObjects variable. Create an Assignment element named "Update Consent Fields" that performs the following assignments:
Variable Operator Value Description {!CurrentAccount.LastConsentedToMarketingDate__pc}
equals {!Today}
Sets Last Consented to Marketing Date
to today's date.{!CurrentAccount.ConsentedToMarketing__pc}
equals
{!$GlobalConstant.True}
Sets Consented to Marketing
to true.Create an Assignment element named "Add to AccountsToUpdate" that performs the following assignment:
Variable Operator Value Description {!AccountsToUpdate}
add {!CurrentAccount}
Adds the CurrentAccount variable (with its updated consent values) to the temporary AccountsToUpdate SObject collection variable. Create a Fast Update element named "Update Accounts" that performs the following assignment:
Variable {!AccountsToUpdate}
- Set the Loop Thru InputSObjects element as the Start element.
- Connect the elements:
- "Loop Thru InputSObjects" goes to "Update Consent Fields" for each value in the collection.
- "Update Consent Fields," goes to "Add to AccountsToUpdate."
- "Add to AccountsToUpdate," goes to "Loop Thru InputSObjects."
- "Loop Thru InputSobjects" goes to "Update Accounts" when there are no more values to process.
Save the flow with with the following values and then activate it.
Name Unique Name Type MarketingConsentProvided
MarketingConsentProvided
Autolaunched Flow
Create the CurrentAccountId query with the following values:
Field Value Query Name CurrentAccountId SELECT Id
SObject Account
WHERE Id = {!CurrentAccountId}
Sharing Mode User
Create the CurrentAccountId data source with the following values:
Field Value Name CurrentAccountId
Class SOQLDataSource
Context CurrentAccountId
Create the Marketing Consent Provided button with the following values:
Field Value Name Marketing Consent Provided
Class NC.DynamicFlowButton
Heading Label I Consent
Object Account
Data Source CurrentAccountId
Configuration MarketingConsentProvided
Create a Card with an Access Control
Before creating an access control, a formula field is required to contain the logic that determines which logged in constituents should see the card.
Create a
Marketing Consent Required
account field with the Formula (Text) data type. When the formula is true, the Marketing Consent Alert card displays. Consider which constituents should see the card and when.
For example, this formula results in a card that displays only to Italian or French constituents who have never consented to marketing or who have not consented to marketing in the last 365 days (for an association that has set their Consent Request Frequency Privacy Setting set to 365):CODEAND( OR( PersonMailingCountry = 'Italy', PersonMailingCountry = 'France'), OR( ISBLANK(LastConsentedToMarketingDate__pc), TODAY() - $Setup.PrivacySettings__c.ConsentRequestFrequency__c > LastConsentedToMarketingDate__pc) )
If you need to specify several countries, it may be easier to offload that logic onto a query record and use the SOQL "IN" notation. For example:
WHERE PersonMailingCountry IN ('Country 1', 'Country 2', 'Country n')
.Yet another option is to use the VLOOKUP function (external) in the formula, particularly if you want to track the country list more formally in a custom object.
Create the Marketing Consent Required access control with the following values:
Field Value Name Marketing Consent Required
Class AccountConditional (NC)
Query Record Name Marketing Consent Required
Is Active TRUE
Create the Marketing Consent Alert card with the following values:
Field Value Type Plain Text
Name Marketing Consent Alert
Access Control Marketing Consent Required
CSS Class m-card-as-alert alert-info Heading Label Marketing Consent
Description Label I have read and I agree to the privacy policy, and understand how the association uses my data for marketing purposes.
Button Marketing Consent Provided
If you want to include HTML tags in the Description Label, such as a link to your privacy policy, set the Card Layout to Display HTML.
This is just one way you can set up consent tracking for specific accounts in Community Hub. You can create your own components to customize the experience for your constituents, just be sure that whatever approach you take complies with the data protection and privacy regulation(s) to which you are adhering.
This recipe only created the button and flow for a constituent that provides consent. You would generally want to provide a separate button and flow so constituents can decline providing consent. The button could be added to the Marketing Consent Alert card alongside the Marketing Consent Provided button.