---
schema_version: "1"
id: aca904729299d58806eafeb9645c488b2bd2b8202005434020d8c47f7afb93e1
title: Use Marketing Object Data in Messages
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/mktg/264-0-0/mktg_data_objects_use.md
canonical_url: https://help.salesforce.com/s/articleView?id=mktg.mktg_data_objects_use.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: c64a4e23df985b6b642a6c1088b4ca1f5cbcd6f63ef3602eee206e63afd07e06
description: To include data from marketing objects in your messages, use AMPscript or Handlebars code. You can include AMPscript and Handlebars in messages that you create by using the visual editor, or messages you create by using the API.
products:
  - Marketing
release: "264"
---
# Use Marketing Object Data in Messages

To include data from marketing objects in your messages, use AMPscript or Handlebars code. You can include AMPscript and Handlebars in messages that you create by using the visual editor, or messages you create by using the API.

[View supported editions](https://help.salesforce.com/s/articleView?id=mktg.mktg_editions.htm&release=264.0.0&type=5 "Marketing Cloud Next is available in Growth and Advanced editions, and requires Salesforce Enterprise or Unlimited editions. Some features are limited by edition or purchased add-on. All functionality is available in Lightning Experience only.").

## Field Identifiers

Each marketing object has a unique identifier, which consists of the API name for the object followed by `__mo`. For example, if the API name of a marketing object is `CustomerRewardMembers`, the unique identifier for the marketing object is `CustomerRewardMembers__mo`.

The fields in the marketing object have identifiers that end with `__c`. For example, if the API name for a field in a marketing object is `RewardsPoints`, the identifier for the field is `RewardsPoints__c`.

Use these identifiers with the [AMPscript Lookup() function](https://developer.salesforce.com/docs/marketing/marketing-cloud-ampscript/references/mc-ampscript-data-extension/mc-ampscript-reference-data-extension-lookup.html) or the [Handlebars QueryFirst helper](https://developer.salesforce.com/docs/marketing/handlebars-for-marketing-cloud-next/references/mcn-handlebars-utility-references/mcn-handlebars-reference-utility-queryfirst.html) to retrieve data from a marketing object.

## Data Graph Data

You can also retrieve fields from the data graph for your account. A data graph contains attributes that you can use to personalize your messages. Each Marketing Cloud Next account or business unit has a default data graph. The identifier for a data graph field is `$dataGraph.` followed by the field name. For example, to reference the `Email` field in your data graph, use `$dataGraph.Email__c`. For more information about data graphs in Marketing Cloud Next, see [Set Up Personalization Features in Marketing Cloud Next](https://help.salesforce.com/s/articleView?id=mktg.mktg_data_graph_setup.htm&release=264.0.0&type=5 "When you personalize marketing messages using merge fields or dynamic content, you can improve the customer experience and increase engagement. Before you can start personalizing content, set up Personalization and configure a data graph based on the Unified Individual object. A data graph is also necessary for personalizing flow decisions.").

## Usage Example

As an example, assume that you have a marketing object called CustomerRewardMembers, which contains the data in this table:

   
| **FirstName** | **LastName** | **EmailAddress** | **RewardsPoints** |
| --- | --- | --- | --- |
| Sarah | Johnson | johnsonsarah@example.com | 1250 |
| Michael | Chen | michael.chen@example.com | 3420 |
| Alina | Rodriguez | arodriguez@example.com | 6742 |
| Amit | Patel | amit.patel@example.com | 890 |
| Myali | Brown | myali.brown@example.com | 2150 |

If you want your message to include the subscriber's reward point balance, specify the identifier of the data object (`CustomerRewardMembers__mo`) and the identifier of the column to return (`RewardsPoints__c`). Next, cross-reference the email addresses in the marketing object (`EmailAddress__c`) with the target email addresses in your data graph (`$dataGraph.Email__c`). The AMPscript code resembles this example:

```
%%[
SET @points = Lookup(
    CustomerRewardMembers__mo, 
    RewardsPoints__c, 
    EmailAddress__c, 
    $dataGraph.Email__c)
]%% 
  
<p>Your reward points balance is %%=v(@points)=%%!</p>
```

Alternatively, to render this content by using Handlebars, use this example:

```
{{set points=(
  get 
    (queryFirst 
      type="MO" 
      object="CustomerRewardMembers__mo" 
      EmailAddress__c=$dataGraph.Email__c
    ) 
    "RewardsPoints__c"
)}}

<p>Your reward points balance is {{points}}!</p>
```

With this code in place, Michael Chen’s email says “Your reward points balance is 3420!” and Myali Brown’s email says “Your reward points balance is 2150!”

## Preview and Test Message Content

Before you publish an email that contains AMPscript or Handlebars code, preview and test it to make sure that your code produces the expected result. Verify that the correct data appears for several recipients and that your content renders properly. For more information, see [Create an Email in Code View in Marketing Cloud Next](https://help.salesforce.com/s/articleView?id=mktg.mktg_content_email_html_create.htm&release=264.0.0&type=5 "In code view, view and edit message HTML and CSS for custom control over your email design. Also, advanced users can use Handlebars templating language to add scripting and conditional logic and perform data lookups. As you author, code view provides syntax validation, inline coding assistance, and search. Preview and test the email and publish it for use with a campaign. To change a published email or prevent it from sending in a campaign, you can unpublish it.").