[GA4] Import cost data

Do not upload a file that includes duplicate keys. Doing so may result in data reporting issues like double counting. All imported campaign rows without a match will still be included in the reporting.

Cost-data import lets you analyze return-on-investment (ROI) and compare campaign performance for all your online-advertising and marketing investments.

How cost-data import works

Google Analytics uses cost-data import to join your imported data generated from campaigns outside of Google, like email and social media advertising, with revenue and key events data from Analytics. This allows you to calculate metrics, such as non-Google cost per click/conversion and return on non-Google ad spend, from these campaigns in Analytics for each campaign, source, and medium.

Cost-data import lets you compare performance data across all your ad initiatives. You can see this data in the Acquisition > Non Google cost report and on the Planning > All channels report in the Advertising workspace.

Because the true costs for ads change as campaigns run, you can upload data periodically for the same campaign IDs and Analytics will use the most recent values for reporting and exploration.

Note: We expect the currency of cost that is imported to match the GA4 property currency.
Google Analytics will report your cost, impressions and/or clicks on any combination of the imported required dimensions.

The role of custom campaign URLs

The key to performing ROI analysis on paid campaigns is adding custom campaign parameters to all destination URLs in the non-Google ad system you're using. This lets you join cost data from those external sources with session data in Analytics.

Example of custom campaign parameters

A pet store is running a summer sale. They tag the destination URL contained in their advertisement with campaign tracking parameters (utm_id, utm_campaign, utm_source, utm_medium). The resulting URL would look something like this:

http://www.examplepetstore.com?utm_id=123_1a2b3c_abc&utm_campaign=Summer%2BSale&utm_source=ad%2Bnetwork&utm_medium=cpc&utm_term=cpc_keyword&utm_content=hero

When the user clicks an ad with this URL, their visit to the examplestore website can be associated with the Summer Sale campaign. Analytics will set the following values for the session:

Dimension name in Analytics Custom campaign parameter Value set in Analytics
Campaign ID utm_id 123_1a2b3c_abc
Campaign utm_campaign Summer Sale
Source utm_source ad network
Medium utm_medium cpc

For Google Analytics 4 properties, Campaign ID (utm_id), Campaign (utm_campaign), Source (utm_source), and Medium (utm_medium) are required.

You can include additional parameters in your URLs that are traditionally used in Universal Analytics properties like Campaign Term (utm_term) and Campaign Content (utm_content) if you like, but they are not required and cannot be included in the import file.

This ensures that Analytics has the campaign-tracking parameters associated with the session and that there is a way to join Analytics data with the external cost-data source for reporting purposes.

Google Analytics will report your cost, impressions and/or clicks on any combination of the imported required dimensions.

Create a CSV file

Create a CSV file of cost dimensions and metrics (see the template below).

Upload the data

The general upload procedure is outlined in About Data Import.

When you create the data source, select Cost data.

When you map Analytics fields to your imported fields, you'll see something like the following:

In the first column you'll see:

  • The Analytics fields (in this case, Campaign ID, Campaign source, Campaign medium, Campaign name, Date) on which you're joining your data. Also called the schema keys.
  • Campaign dimensions and metrics that match the fields in your CSV. (e.g., Daily cost, Daily clicks, etc.)

Campaign ID, Campaign source, Campaign medium, and Campaign name match the custom campaign parameters utm_id, utm_source, utm_medium, and utm_campaign that you used in your destination URL.

In the second column, you select the matching fields in your CSV:

After you upload your data, it can take up to 24 hours for Analytics to make that data available in reports, audiences, and explorations. Users have to engage with your campaign after you upload the data in order for those metrics and campaign properties to be associated with user activity.

You can overwrite metric and dimension values by uploading new ones.

Since cost-data import uses the reporting/query time join and does not alter data that has already been processed, you can simply delete a cost-data source from the data-upload service to remove cost data from Analytics reports. 

Data-source details

Legend

  • Scope: the scope determines which events will be associated with the import-dimension values. There are four levels of scope: hit, session, user and product. Learn more about scope
  • Schema: lists the dimensions and metrics that make up the structure of your imported data. Your upload file headers must match the schema you define for that data source.

The dimensions and metrics listed for the schema are for reference only and may not be complete; the actual dimensions and metrics available will appear in the user interface when you create the data source.

Scope This data has no scope because it is daily aggregated data and summarizes many events across sessions and users for each day.
Schema

The following dimensions are required:

  • Campaign ID (utm_id)
  • Source (utm_source)
  • Medium (utm_medium)
  • Campaign name (utm_campaign)
  • Date (ISO 8601: YYYY-MM-DD)

At least one of the following metrics is required:

  • Clicks (daily value) (optional)
  • Cost (daily value in the format 0,000.00) (optional, but expected)
    • Note: We expect the currency of cost that is imported to match the GA4 property currency.
  • Impressions (daily value) (optional)

Template

Here is an example CSV template for cost data. If you need to create your upload files by hand, use this example as a guide.

utm_id utm_campaign utm_source utm_medium date impressions clicks cost
bing_123abc Summer_fun bing cpc 2020-12-01 12242371 367271 36727.10
facebook_456def Fall_delight facebook cpc 2020-12-01 3429267 34292 8573.00
twitter_789ghi Winter_wonderland twitter cpc 2020-12-01 9732461 194649 29197.35

 

 

Importing cost data from other platforms

The following sections provide general guidelines for exporting campaign cost data from different platforms (e.g., Facebook, Twitter, Microsoft), and also provide available links to the native documentation for those platforms.

Given that those platforms don't necessarily supply data using the same format that is native to Analytics, it is up to you to ensure that the data you export from those platforms and import into Analytics is consistent with the format that Analytics expects (e.g., id, source, medium, date).

Make sure the data you export matches (but does not exceed) the following required, recommended, and optional dimensions and metrics:

  • ID [required]
  • Source [required]
  • Medium [required]
  • Date [required]
  • Name [optional, but recommended]
  • Cost (optional, but expected)
    • Note: We expect the currency of cost that is imported to match the GA4 property currency.
  • Clicks (optional)
  • Impressions (optional)

Collecting campaign IDs

Various vendors, including those below, provide different mechanisms to include campaign id, name, source, and medium within an ad's click target (the link to your site that end users click). We advise using vendor-provided auto-population features when they're available. When those features are not available, you may have to provide full URLs directly to the vendor.

Facebook

Use Facebook Ads Manager to export your data.

  1. In Ads Manager, click the Export & Import icon.
  2. Select the option to customize your export to include the dimensions and metrics listed above.

Related resources

Differences Between Ads Manager Field Names and Import/Export Spreadsheet Column Names

Firebase Android apps

Use the campaign_details event to collect the equivalent information you collect with utm_id for web campaigns.

Use FirebaseAnalytics.Param.CP1 (custom parameter) to collect the information.

Firebase iOS apps

Use the AnalyticsParameterCampaign constant to collect the equivalent information you collect with utm_id for web campaigns.

LinkedIn

Use Campaign Manager to export campaign data.

  1. Select Campaign performance as the Report Type so you can choose which Column view to use for your CSV export.
  2. Select only the dimensions and metrics listed above (or the import will fail).

Related resources

Microsoft

You can use Microsoft Advertising reports to export a CSV file of your data.

  1. Configure a campaign report that includes the dimensions and metrics listed above.
  2. Use the Download option to export your data.

You can also use Microsoft Advertising Editor to export data for campaigns.

Twitter

Use the Export option in the upper right section of your campaign dashboard to export a CSV file of your campaign data.

Twitter does not provide native support for Source and Medium. You can hard code the source as "twitter". The values you provide for Medium should reflect the individual mediums you use for each campaign ID.

Verizon

Use Native Ad Platform bulk files to download and edit the campaign data from your advertiser account.

The default download includes additional dimensions that you cannot import into Analytics. Prior to import, you need to remove those columns and consolidate rows as necessary so that your CSV file includes only the dimensions and metrics listed above (or the import will fail).

Limits of cost-data import

Cost-data import uses the reporting/query time join. This lets you associate your imported cost data with events already processed by Analytics.

You can have only one data source when you import cost data.

Note: We expect the currency of cost that is imported to match the GA4 property currency.

Was this helpful?

How can we improve it?
Search
Clear search
Close search
Main menu
9106599558948303851
true
Search Help Center
true
true
true
true
true
69256
true
false