Custom metrics: Resources and tips

Building custom metrics or modelled data sources and looking for help? This article includes links to descriptive articles for several key services as well as tips on retrieving (querying) data.

Each service's API is unique. When you select a data view and columns and apply filters, you're specifying the data you want to retrieve (query) from a service. Because each service's API is unique, it may be difficult to understand how to effectively narrow down the data you're looking for. For example, it may be unclear that a particular data view includes required filters or in what format the operators and values need to be entered. You might notice some services here don't include tips. We'll keep updating this article and adding more tips as we investigate and resolve the intricacies of each service's API.

Query only the data you need. By filtering to pinpoint only the data you need, you optimize the volume of data being queried. This not only makes your data easier to understand and handle, it often makes the query run faster. Learn more about filtering for custom metrics.

This article includes links to resources and tips for requesting and filtering data for the following services:

Facebook

Resources

Query tips

  • Data view: SimpleInsights

Tip: Under Data view filters > InsightName, you'll see a long list of items. The following insights are not displayed in the list but they are available for selection: "page_daily_follows", "page_daily_follows_unique",  "page_daily_unfollows", "page_daily_unfollows_unique" , and page_follows". 

Facebook Ads

Resources

Query tips

  • Data Views: AdInsights and AdInsightsActions

Tip: Under Columns > DateEnd, when applying a filter, the "On or before" operator does not return results. The "Is", "Before", and other operators work as expected.

Google Ads

Resources

Query tips

  • Data view: All views that include a date column, when you want to retrieve data for a date range.

Tip: By default, the Google Ads API returns a single day of data. If you want to retrieve a range of data, under Columns, select Date and add the following filters: Add "On or after" as the first operator (and select the beginning of the date range). Then, add "On or before" as the second operator (and select the end of the date range).

Note that there are some exceptions, for example, "ClickView", which must be filtered to limit results to one day.

  • Data view: All views that include a date column, when you want to retrieve data for a single day or when results are limited to a single day of data, for example, when selecting “ClickView”.

Tip: Under Columns, select Date and apply a filter limiting the data returned to a single day. When applying the filter, you must use the “Is” operator.

Google Analytics (Universal Analytics)

Resources

Query tips

  • Data view: All views that include "Metrics" or "Dimensions" as optional columns.

Tip: When applying filters for the columns "Dimensions" or "Metrics", if you apply multiple filters, the values will be returned as a comma separated list in a single column. You'll need to add a new column for each member and write a formula using SUBSTRING and INDEXOF to isolate the individual entries.

To explain this further, we'll use an example that selects Traffic as the data view and Date, Dimensions, and Sessions as the columns. We'll apply filters to the Dimensions column to see data by continent and by age group. (See below.)

After previewing your data and clicking Save and continue you enter the modeller. Here you will add a new column for Continent and a new column for Age. For each new column, you'll write a formula using SUBSTRING and INDEXOF.

  1. In the modeller, add a new column for Age, by clicking the + sign.
  2. In the formula bar, with the new column selected, enter the following:

SUBSTRING(&Dimensions,INDEXOF(&Dimensions,",")+1)

  1. By entering the formula above, you refer to the "Dimensions" column and isolate the age related information by single entry. Next, select the column header row and change its name to Age. (See below.)

  1. Add a new column for Continent by following the same method as above but altering the formula slightly, as shown below:

SUBSTRING(&Dimensions,0,INDEXOF(&Dimensions,","))

Google Analytics 4

Resources

HubSpot v2

Resources

Query tips

  • Data view: Engagements

Tip: Under Columns, when applying a date filter, select "UpdatedAt" (not "CreatedAt").

HubSpot v3

Resources

Instagram Business

Resources

LinkedIn Ads

Resources

LinkedIn Pages

Resources

Query tips

  • Data view: CompanyUpdateStatistics

Tip: Under Columns > TimeRangeEnd and Columns > TimeRangeStart, when applying filters to specify a date range for your query, you must use the "On or before" operator for TimeRangeEnd and the "On or after" operator for TimeRangeStart. You can optionally set the "TimeGranularity" query filter to "DAY" or "MONTH" to control the resolution of the data returned. 

Note: If you don't specify a date range for your query, it will use the default (lifetime statistics).

  • Data view: CompanyPageStatistics

Tip: Under Columns > ReportTimeRangeEnd and Columns > ReportTimeRangeStart, when applying filters to specify a date range for your query, you must use the "Is" or "On or before" operators for ReportTimeRangeEnd and the "Is" or "On or after" operators for ReportTimeRangeStart. You can optionally set the "TimeGranularity" query filter to "DAY" or "MONTH" to control the resolution of the data returned.

Note: If you don't specify a date range for your query, it will use the default (lifetime statistics).

Mailchimp

Resources

QuickBooks

Resources

Salesforce

Resources

Query tips

Stripe

Resources

Query tips

  • Data View: Subscriptions

Tip: Under Columns, you cannot apply date filtering for CurrentPeriodStart or Start. However, you can apply date filtering for CreatedAt.

Twitter

Resources

Query tips

  • Data View: Users

Tip: To get data for a specific user ID, under Data view filters, select +Add filters (optional) > User_ID and click Apply.  You must enter a specific account ID as the filter value, otherwise the data view uses the default setting and returns data for Twitter's account.

Twitter Ads

Resources

Xero

Resources

YouTube

Resources

Query tips

  • Data view: TimeBasedReports and TopVideos

Tip: To get data for a specific playlist using either of these data views, under Data view filters:

  1. Click +Add filters (optional), select the checkboxes beside “IsCurated” and “Playlist”, and click Apply. Click the Click to add filter box for each one. For “Is Curated”, set Equals as the operator and true as the value. For “Playlist”, set Match All and Equals as the operators and enter your playlist Id as the value.
  2. Under Columns, select one or more of “AverageTimeInPlaylist”, “AverageViewDuration”, “EstimatedMinutesWatched”, “PlaylistStarts”, “Views”, and “ViewsPerPlaylistStart”.

Note: You must also select “Day” as a column for TimeBased Reports.

Zendesk

Resources

Query tips

  • Data views: Tickets and TicketMetrics

Tip: When applying filters to specify a date range for your query (for example, “CreatedAt”) you must select the “After” or “On or after'' operators (along with the “Before” or “On or before” operators to further constrain the query to a specific date range). The “Is” operator for a single date is not supported and will not return data. For example, to get today’s data, try “On or after” and “Today”, instead of “Is” and “Today”.

  • Data views: Any data view that can potentially retrieve a very large amount of data and to which you’ve added complex filter conditions. This example describes selecting the “Users” data view from Zendesk and applying the following filters to the “Role” column: “Role” = “agent” and “Role” = “admin”. Because the filter condition applies to two values (agent and admin) PowerMetrics needs to retrieve all of the users from your account and filter the results. Since Zendesk accounts typically include a large number of users this can result in a long running query that times out. By simplifying the filter condition to use only one value, such as "Role" = "agent" only, the query can be executed directly by Zendesk and returning results much quicker.

Tip: To resolve this issue, split your data by creating two separate data sources, in this case, create one data source for users with the agent role and one for users with the admin role. Then merge the two data sources into one that you can use for your metrics. Learn how to merge data sources in the modeller.

Have more questions? Submit a request