Skip to main content
Skip table of contents

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:

To make this recipe, you should understand:


You will mix these ingredients together to make this recipe:



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.

CurrentAccountIdQueryQueries the account ID of the constituent currently logged into Community Hub.
CurrentAccountIdData SourcePasses the CurrentAccountId query to the Marketing Consent Provided button.
Marketing Consent ProvidedButtonIn Community Hub, logged in constituents click this button to run the MarketingConsentProvided flow.
Marketing Consent RequiredAccess ControlReferences a formula field on the logged in constituent's account record to determine if the Marketing Consent Alert card should display.
Marketing Consent AlertCardIn Community Hub, this card displays a message and the Marketing Consent Provided button to logged in constituents.


Create Custom Consent Fields

Custom consent fields track whether constituents have consented to having their data used for marketing purposes.

  1. Create the following custom fields on the Contact object:

    Field LabelSuggested API NameField TypeDescription
    Consented to MarketingConsentedToMarketingCheckboxIf true, the constituent has consented to having their data used for marketing purposes.
    Last Consented to Marketing DateLastConsentedToMarketingDateDateThe 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

  1. Using Cloud Flow Designer, create the MarketingConsentProvided flow:
    1. Create SObject resources with the following values:

      Resource TypeUnique NameInput/Output TypeObject TypeDescription
      SObject Collection VariableInputSObjectsInput OnlyAccountThe account records passed in as inputs from the Marketing Consent Provided button.
      SObject VariableCurrentAccountPrivateAccountThe current iteration in the loop through the InputSObjects SObject collection variable.
      SObject Collection VariableAccountsToUpdatePrivateAccountThe temporary SObject where the loop stores the updated marketing consent field values.
    2. Create a Formula resource with the following values:

      Resource TypeUnique NameValue Data TypeFormulaDescription
      FormulaTodayDateTODAY()Returns today's date.
    3. Create a Loop element named "Loop Thru InputSObjects" with the following values:

      Loop throughLoop VariableDescription
      {!CurrentAccount}Loops through the InputSObjects variable.
    4. Create an Assignment element named "Update Consent Fields" that performs the following assignments:

      {!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.
    5. Create an Assignment element named "Add to AccountsToUpdate" that performs the following assignment:

      add{!CurrentAccount}Adds the CurrentAccount variable (with its updated consent values) to the temporary AccountsToUpdate SObject collection variable.
    6. Create a Fast Update element named "Update Accounts" that performs the following assignment:

    7. Set the Loop Thru InputSObjects element as the Start element.
    8. Connect the elements:
      1. "Loop Thru InputSObjects" goes to "Update Consent Fields" for each value in the collection.
      2. "Update Consent Fields," goes to "Add to AccountsToUpdate."
      3. "Add to AccountsToUpdate," goes to "Loop Thru InputSObjects."
      4. "Loop Thru InputSobjects" goes to "Update Accounts" when there are no more values to process.
      Show Me an Image...

    9. Save the flow with with the following values and then activate it.

      NameUnique NameType
      MarketingConsentProvidedMarketingConsentProvidedAutolaunched Flow
  2. Create the CurrentAccountId query with the following values:

    Query NameCurrentAccountId

    WHEREId = {!CurrentAccountId}
    Sharing ModeUser
  3. Create the CurrentAccountId data source with the following values:



  4. Create the Marketing Consent Provided button with the following values:

    NameMarketing Consent Provided


    Heading LabelI Consent
    Data SourceCurrentAccountId

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.

  1. 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):

        PersonMailingCountry = 'Italy',
        PersonMailingCountry = 'France'),
        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.

  2. Create the Marketing Consent Required access control with the following values:

    NameMarketing Consent Required
    ClassAccountConditional (NC)
    Query Record NameMarketing Consent Required
    Is ActiveTRUE
  3. Create the Marketing Consent Alert card with the following values:

    TypePlain Text
    NameMarketing Consent Alert
    Access ControlMarketing Consent Required
    CSS Classm-card-as-alert alert-info
    Heading LabelMarketing Consent
    Description LabelI have read and I agree to the privacy policy, and understand how the association uses my data for marketing purposes.
    ButtonMarketing 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.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.