Overview: HubSpot Marketing Email Query Builder

In this article, we will create a custom metric using the HubSpot Marketing Email Query Builder in order to highlight key functionalities of the tool. For our example, we will create a new Custom Metric that returns the number of Email Opens for non-Newsletter Emails. 


  1. Basic Options
  2. Advanced Options
  3. Data Preview
  4. Additional Info

1. Basic Options

  Custom Metric Name (required): Create a name for your Custom Metric in this field. You will find this Metric Name in the Designer after saving.
We chose "Emails Opened (excluding Newsletters)" for our Custom Metric name.
  Metric (required): Select an Email Metric from your connected HubSpot Data Source, such as Sent, Opened, Bounced, Contacts Lost, etc.

We chose "Opened" as our Metric selection.

  Select Emails  (optional): If you have a specific set of emails you'd like to report on, you can manually select them here. Emails are combined using "AND" boolean logic. 
  Email Filters (optional): After selecting the "Email Name" property, you can choose use the conditions "contains" or "does not contain" to add Filters to the Custom Metric. Filters can be combined using "AND" | "OR" boolean logic. Filtered queries restrict the rows that do (or do not) get included in the result. Each row in the result is tested against the filter. If the filter matches, the row is retained. If it doesn't match, the row is dropped.

2. Advanced Options

    Group and Summarize Email Values (optional): By default, the query will return a list of Email Names and their associated values. This is great to display on a Table or Pie Chart. There are also cases where it's valuable to have 1 total number to refer to instead. In order to do this, select the "Group and Summarize Email Value" option. This will aggregate all of the individual email values that were returned into one high level Metric. 
When everything mentioned above is set, click  Run query to generate the Data Preview.

3. Data Preview

In the Data Preview, you will see the total values returned for the current day. 

If you want to sort values by date/ time just click on the arrow next to "Date"

When your Custom Metric is ready, click Save query. This creates a Custom Metric under your HubSpot Marketing Data Source, with the Custom Metric name you specified in section A (i.e., Emails Opened (excluding Newsletters)).

By default, the Custom Metric will be added within the Data Source that the data is pulled from. It is possible to change the Target Data Source by clicking on Target data source hyperlink in the top right of the Query Builder. Unless this is necessary for a specific use case, we do not recommend changing the Target Data Source. 

4. Additional Info

  1. Custom Metrics built using the Email Query Builder will still have an open "start date," meaning a Custom Metric like "Emails Opened (excluding Newsletter)" will show the total number of non-Newsletter Emails that were ever opened up until the end of the specified Date Range. 
  2. If there is no data returned for Today, no data will be displayed in the Data Preview. 
  3. Data is only available for Emails that have gone live. 

Still need help? Contact Us Contact Us