A Consent Swiss Army Knife for Marketing Cloud Next Segments and Flows

Tips from the Trenches #027
Use a Calculated Insight to resolve email subscription consent across multiple addresses and apply opt-in rules in Marketing Cloud Next Segments and Flows.
On this page

Email subscription consent is recorded for a contact point, but marketers often need to make decisions about an entire Unified Individual. When a profile has several email addresses, each address can have a different preference for the same subscription. Depending on the use case, you may want to include anyone with at least one opted-in address, require every address to be opted in, or identify profiles with no opt-ins.

In this article, we’ll build a reusable Calculated Insight that turns those address-level preferences into two counts per Unified Individual and Email subscription: addresses with an opt-in and addresses without one. Where several consent records exist for the same address and subscription channel, the query selects the latest recorded consent before counting.

Examples include filtering profiles before they enter a Flow and routing them according to the selected subscription’s consent counts.

One CI, Multiple Consent Rules

Resolve Consent Across Multiple Email Addresses

Consider a Unified Individual with three email addresses. For the Newsletter subscription, the work address is opted in, the personal address is opted out, and the third address has no recorded consent. Is this profile subscribed? The answer depends on the rule you want to apply: at least one address is opted in, but not all of them are.

A related-record filter looking for Consent Status = OPT_IN answers another question: does a matching opt-in record exist? If several consent records coexist for the same address and subscription channel, an older acceptance could satisfy that condition even when a newer record contains an opt-out.

The CI resolves the consent records first, then counts each distinct email address once per profile and Email subscription. Its two measures distinguish addresses whose selected consent is OPT_IN from those with an opt-out, another status, or no consent record.

Choose “At Least One” or “All Opted In”

The “at least one” rule includes a Unified Individual when OptInEmailCount is greater than zero. In our three-address example, the profile qualifies because the work address is opted in. This does not make the other addresses eligible: Marketing Cloud Next still checks sending consent for each address.

The “all opted in” rule requires OptInEmailCount to be greater than zero and NotOptedInEmailCount to equal zero. The same profile would be excluded because its personal address is opted out and its third address has no consent. Requiring a positive opt-in count also prevents profiles without email addresses from qualifying. This rule covers every distinct email address attached to the profile, so an address without opt-in excludes the whole profile even if another address could receive the email.

We use “not opted in” rather than “opted out” deliberately. The second measure includes explicit opt-outs, missing consent, and any status other than OPT_IN. Both rules can therefore be configured using numeric conditions, without comparing one measure against another.

Create the Calculated Insight

Create the CI with Legacy SQL

In Data 360, open Calculated Insights and click New. Select the data space containing your Unified Individual, unified email contact point, and subscription consent data. Choose Calculated Insight, then Use Legacy SQL.

Create the consent summary in the appropriate data space using the Legacy SQL builder.

Paste the query below into the editor. It discovers the subscriptions configured for the Email channel, so you don’t need to enter subscription names individually. For subscriptions supporting several channels, only their Email consent contributes to the counts.

The query returns two dimensions, UnifiedIndividualId__c and SubscriptionName__c, and two numeric measures, OptInEmailCount__c and NotOptedInEmailCount__c. Subscription names must uniquely identify subscriptions within your scope. If different subscriptions share a name, including across business units, use a subscription ID or additional scope dimension to keep their results separate.

				
					SELECT
    UnifiedIndividual__dlm.ssot__Id__c
        AS UnifiedIndividualId__c,
    EmailSubscriptions.SubscriptionName__c
        AS SubscriptionName__c,

    SUM(
        CASE
            WHEN UnifiedEmail.EmailAddress__c IS NOT NULL
                AND LatestConsent.ConsentStatus__c = 'OPT_IN'
            THEN 1
            ELSE 0
        END
    ) AS OptInEmailCount__c,

    SUM(
        CASE
            WHEN UnifiedEmail.EmailAddress__c IS NOT NULL
                AND LatestConsent.ConsentStatus__c = 'OPT_IN'
            THEN 0
            WHEN UnifiedEmail.EmailAddress__c IS NOT NULL
            THEN 1
            ELSE 0
        END
    ) AS NotOptedInEmailCount__c

FROM UnifiedIndividual__dlm

INNER JOIN (
    SELECT
        ssot__CommunicationSubscription__dlm.ssot__Name__c
            AS SubscriptionName__c,
        ssot__CommunicationSubscriptionChannelType__dlm.ssot__Id__c
            AS SubscriptionChannelId__c,
        ssot__EngagementChannelType__dlm.ssot__Name__c
            AS EngagementChannelName__c

    FROM ssot__CommunicationSubscription__dlm

    INNER JOIN ssot__CommunicationSubscriptionChannelType__dlm
        ON ssot__CommunicationSubscriptionChannelType__dlm.ssot__CommunicationSubscriptionId__c =
            ssot__CommunicationSubscription__dlm.ssot__Id__c

    INNER JOIN ssot__EngagementChannelType__dlm
        ON ssot__EngagementChannelType__dlm.ssot__Id__c =
            ssot__CommunicationSubscriptionChannelType__dlm.ssot__EngagementChannelTypeId__c

    WHERE ssot__EngagementChannelType__dlm.ssot__Name__c = 'Email'

    GROUP BY
        ssot__CommunicationSubscription__dlm.ssot__Name__c,
        ssot__CommunicationSubscriptionChannelType__dlm.ssot__Id__c,
        ssot__EngagementChannelType__dlm.ssot__Name__c
) AS EmailSubscriptions
    ON EmailSubscriptions.EngagementChannelName__c =
        CASE
            WHEN UnifiedIndividual__dlm.ssot__Id__c IS NOT NULL
            THEN 'Email'
            ELSE ''
        END

LEFT JOIN (
    SELECT
        UnifiedContactPointEmail__dlm.ssot__PartyId__c
            AS UnifiedIndividualId__c,
        UnifiedContactPointEmail__dlm.ssot__EmailAddress__c
            AS EmailAddress__c,

        ROW_NUMBER() OVER (
            PARTITION BY
                UnifiedContactPointEmail__dlm.ssot__PartyId__c,
                UnifiedContactPointEmail__dlm.ssot__EmailAddress__c
            ORDER BY
                UnifiedContactPointEmail__dlm.ssot__Id__c DESC
        ) AS EmailRowNumber__c

    FROM UnifiedContactPointEmail__dlm

    WHERE UnifiedContactPointEmail__dlm.ssot__EmailAddress__c IS NOT NULL
        AND UnifiedContactPointEmail__dlm.ssot__EmailAddress__c <> ''
) AS UnifiedEmail
    ON UnifiedEmail.UnifiedIndividualId__c =
        UnifiedIndividual__dlm.ssot__Id__c
    AND UnifiedEmail.EmailRowNumber__c = 1

LEFT JOIN (
    SELECT
        ssot__CommunicationSubscriptionConsent__dlm.ssot__ContactPointValueText__c
            AS EmailAddress__c,
        ssot__CommunicationSubscriptionConsent__dlm.ssot__CommunicationSubscriptionChannelTypeId__c
            AS SubscriptionChannelId__c,
        ssot__CommunicationSubscriptionConsent__dlm.ssot__ConsentStatus__c
            AS ConsentStatus__c,

        ROW_NUMBER() OVER (
            PARTITION BY
                ssot__CommunicationSubscriptionConsent__dlm.ssot__ContactPointValueText__c,
                ssot__CommunicationSubscriptionConsent__dlm.ssot__CommunicationSubscriptionChannelTypeId__c
            ORDER BY
                CASE
                    WHEN ssot__CommunicationSubscriptionConsent__dlm.ssot__ConsentCaptureddateTime__c IS NULL
                    THEN 1
                    ELSE 0
                END ASC,
                ssot__CommunicationSubscriptionConsent__dlm.ssot__ConsentCaptureddateTime__c DESC,
                CASE
                    WHEN ssot__CommunicationSubscriptionConsent__dlm.ssot__LastModifiedDate__c IS NULL
                    THEN 1
                    ELSE 0
                END ASC,
                ssot__CommunicationSubscriptionConsent__dlm.ssot__LastModifiedDate__c DESC,
                ssot__CommunicationSubscriptionConsent__dlm.ssot__Id__c DESC,
                ssot__CommunicationSubscriptionConsent__dlm.ssot__DataSourceId__c DESC
        ) AS ConsentRowNumber__c

    FROM ssot__CommunicationSubscriptionConsent__dlm
) AS LatestConsent
    ON LatestConsent.EmailAddress__c =
        UnifiedEmail.EmailAddress__c
    AND LatestConsent.SubscriptionChannelId__c =
        EmailSubscriptions.SubscriptionChannelId__c
    AND LatestConsent.ConsentRowNumber__c = 1

GROUP BY
    UnifiedIndividual__dlm.ssot__Id__c,
    EmailSubscriptions.SubscriptionName__c
				
			

Validate the expression, then save the CI as Email Subscription Consent. Run it and wait for successful completion before checking the results.

The query counts each distinct email address once per Unified Individual. For each address and subscription channel, it selects consent by ssot__ConsentCaptureddateTime__c descending, followed by ssot__LastModifiedDate__c descending. Record and source identifiers break remaining ties deterministically; they do not establish which consent was captured later.

The successfully processed CI exposes two dimensions and two numeric measures for email subscription consent.

An address contributes to OptInEmailCount__c only when the selected status is OPT_IN. Otherwise, including when no consent record exists, it contributes to NotOptedInEmailCount__c. Profiles without an email address return zero for both measures.

Validate the Consent Counts

After the CI completes successfully, click Explore in Analytics. Switch to a table view and display UnifiedIndividualId__c, SubscriptionName__c, OptInEmailCount__c, and NotOptedInEmailCount__c. Filter by a known Unified Individual and subscription so you can compare the counts with the underlying email addresses and consent records.

For our example with three distinct addresses, one opted in, one opted out, and one without consent, expect OptInEmailCount__c = 1 and NotOptedInEmailCount__c = 2. A profile without an email address should return zero for both measures.

For the Newsletter subscription, this Unified Individual has one opted-in email address and two addresses without opt-in.

Where several consent records exist for the same address and subscription channel, check that the record selected by the query’s ordering determines the count. An older OPT_IN followed by a newer OPT_OUT should contribute to NotOptedInEmailCount__c. After changing a preference, wait for it to reach Data 360 and rerun the CI before checking the result again.

Use the CI in Segment Builder

Include Profiles with at Least One Opted-In Address

Create or edit a Segment based on Unified Individual in the same data space as the CI. In the attribute library, find Email Subscription Consent and drag OptInEmailCount__c onto the canvas. Set the condition to Greater Than 0.

In that metric’s container, click Add Dimension and select SubscriptionName__c. Set it to Is Equal To and enter the intended subscription’s exact name, such as Newsletter. This scopes the count to that subscription; without it, counts can roll up across subscriptions.

Include Unified Individuals with at least one opted-in email address for the Newsletter subscription.

Our example profile qualifies because one of its three addresses is opted in to Newsletter. The Segment includes the whole Unified Individual; it does not remove the other addresses from the profile. Marketing Cloud Next still evaluates sending consent for each address when the email action runs.

This rule is useful when you want profiles with at least one opted-in address to enter the Flow. Profiles with no opted-in addresses are excluded before entry, reducing consent-related NOT_SENT records.

Require All Addresses to Be Opted In

Keep the condition OptInEmailCount__c > 0, then add NotOptedInEmailCount__c as a second metric container. Set it to Is Equal To 0 and combine the two containers with AND.

In each container, add the dimension filter SubscriptionName__c = Newsletter. Both measures must evaluate the same subscription. This includes profiles with at least one email address and no address lacking opt-in.

Include profiles only when every attached email address is opted in to the Newsletter subscription.

Our three-address example no longer qualifies: its NotOptedInEmailCount__c is 2. In the screenshots, adding this condition reduces the audience from 225 to 220 Unified Individuals.

This stricter rule excludes the whole profile when any attached address lacks opt-in for Newsletter, even if another address could receive the email. Use it when that profile-level exclusion is intentional; use the “at least one” rule when one opted-in address is enough.

You can also use the CI to create reusable exclusion Segments. For example, filter OptInEmailCount__c = 0 for the intended SubscriptionName__c, then reuse that Segment in the Exclude criteria of other audiences. This identifies profiles with no opted-in email addresses, including those with missing consent; it does not mean every address has an explicit opt-out.

Use the CI in a Flow

Add the CI to the Data Graph

To use the counts in a Flow Decision, edit the Data Graph used by your segment-triggered Flow. At the Unified Individual root, add the Email Subscription Consent CI, whose UnifiedIndividualId__c dimension associates each result with its profile.

Include SubscriptionName__c, OptInEmailCount__c, and NotOptedInEmailCount__c, then save the graph. The subscription dimension lets each Decision evaluate the intended subscription using the same reusable CI.

Refresh the Data Graph after the CI has completed successfully. Running the CI alone does not update results already materialized in the graph; the Flow can use the updated counts once the graph refresh completes.

Add the subscription dimension and both consent measures to the Data Graph for use in Flow Decisions.

Configure a Consent Decision

In your segment-triggered Flow, add a Decision element and create an outcome named At Least One Opt-In. Select OptInEmailCount__c from the Email Subscription Consent CI in your Data Graph, set the operator to Greater Than, and enter 0.

Under Add Dimension, select SubscriptionName__c and require it to equal the intended subscription’s exact name, such as Newsletter. This scopes the count to that subscription for the current Unified Individual. Keep the default outcome for profiles whose count is zero or whose CI result is unavailable.

Route the current Unified Individual according to whether at least one email address is opted in to Newsletter.

For the “all opted in” rule, add a second condition requiring NotOptedInEmailCount__c = 0. Apply the same SubscriptionName__c = Newsletter dimension filter to this measure, and combine the two metric conditions with AND.

The outcome then requires at least one opted-in address and no address lacking opt-in for the selected subscription. Keep the default outcome for profiles that do not meet both conditions.

Follow the All Opted In outcome only when Newsletter has at least one opted-in address and no address lacking opt-in.

Save the Flow and debug it with profiles whose CI results you have checked. Our three-address example should follow the “at least one” outcome but fail the “all opted in” rule. A profile with only opted-in addresses should satisfy both rules, while a profile with no opted-in addresses should follow the default outcome.

Test the two rules separately, or place the stricter “all opted in” outcome first if both are in the same Decision. Flow evaluates outcomes in order, so an “at least one” outcome placed first would also catch profiles whose addresses are all opted in.

After changing consent, wait for the update to reach Data 360, rerun the CI, and refresh the Data Graph before repeating the debug test. Check both the subscription dimension and the counts if the Flow takes an unexpected path.

Plan Refreshes and Credit Consumption

Keep Consent Results Current

The CI provides a prepared view of consent, so its results depend on refresh timing. A preference change must first reach the consent DMO, then be processed by the CI. Segment Builder uses the processed results when segment membership is recalculated. A Flow Decision using the Data Graph also needs that graph to refresh before it sees the updated counts.

Coordinate these schedules around your required freshness. For a planned campaign, allow consent ingestion to complete, run the CI, then refresh the Segment and, where used, the Data Graph before starting the Flow.

These counts support audience selection and custom Flow routing; they do not replace Marketing Cloud Next’s built-in send-time consent checks. A profile can qualify when the Segment is published and withdraw consent before the send action runs.

Estimate Credits with a Numerical Example

CI refreshes contribute to the Batch Calculated Insights usage category. Consumption is based on the records in the underlying DMOs used by the calculation, taking data-space filters into account, rather than the number of rows returned by the CI.

For example, suppose those DMOs contain 200,000 Unified Individuals, 300,000 unified email contact points, 499,700 subscription consent records, and 300 records across the subscription and channel reference objects. Together, they represent one million underlying records.

At the rate shown in our org, 15 Data Services credits per million records, one execution consumes 15 credits. Over 30 days, daily executions would consume 450 credits, executions every six hours would consume 1,800, and hourly executions would consume 10,800.

This simulation assumes stable record volumes and that every scheduled refresh executes. Check the multiplier applicable to your org. Segment processing and Data Graph refreshes have their own consumption and are not included in these figures.

Batch Calculated Insights consumption is shown separately, with a multiplier of 15.

Final Thoughts

One consent summary can support several business rules. Use OptInEmailCount__c > 0 when one opted-in address is enough, or combine it with NotOptedInEmailCount__c = 0 when every attached address must be opted in. The same CI covers your Email subscriptions and can be reused in Segment Builder and Flow Decisions.

The choice remains a business decision: excluding an address and excluding an entire profile have different consequences. Make that distinction explicit, validate the counts against known profiles, and coordinate refreshes so your audience and Flow logic use sufficiently current results.

That is the “Swiss Army knife” approach: resolve the consent records once, then reuse the counts wherever you need a profile-level decision.

Be informed when we publish new content or have any questions? Join the TAM Slack workspace ↓

Share the Post:

How useful was this post?

Click on a star to rate it!

Average rating 0 / 5. Vote count: 0

No votes so far! Be the first to rate this post.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Join a vibrant 2,000+ member community

Your questions, answered.
Get our latest articles.