[UA] Campaign Data import example [Legacy]

Learn how to use an email campaign ID to import related Source and Medium dimensions.
You are viewing a legacy article about Universal Analytics. Learn more about Google Analytics 4 replacing Universal Analytics.

Importing advertising campaign-related dimensions, such as Source and Medium, allows you to expand and reuse your existing non-Google campaign codes.

In this article:

Scenario

You want to import the Medium and Source for each campaign ID that you use in your URLs. For example, you run email campaigns that contain links tagged with utm_id. You want traffic from these links to be identified with the proper Medium and Source in your reports.

Step One: Decide what data to import

Each of your campaign links includes a utm_id parameter (e.g., http://example.com/landingpage?utm_id=123xyz). You maintain a data file outside of Analytics that associates each utm_id with a Medium and a Source and you plan to upload this information into Analytics. Once this information has been uploaded, Analytics will retrieve the Campaign ID from a URL's utm_id parameter, and then join the hit data with the Medium and Source that are associated with that particular Campaign ID. If, for example, you upload a data file that associates the Campaign ID "xyz" with a Source of "Spring Newsletter" and a Medium of "Email", all the sessions with ?utm_id=xyz will have a Source of "Spring Newsletter" and a Medium of "Email".

Step Two: Create any needed custom dimensions or metrics

Both Medium and Source are already valid dimensions in Analytics, so no custom dimensions are needed.

Step Three: Create the Data Set

  1. Sign in to Google Analytics.
  2. Click Admin, and navigate to the property to which you want to upload data.
  3. In the PROPERTY column, click Data Import.
  4. Click New Data Set.
  5. Select Campaign Data as the Type.
  6. Name the Data Set: Campaign ID Details
  7. Select one or more views in which you want to see this data.
  8. Define the Schema:
    Key: Campaign Code
    Imported Data: Source, Medium
    Overwrite hit data: Yes
    Click Save.

Step Four: Create the CSV

Generating your upload CSV file is a 2-step process:

1. Get the header for the CSV

In the Data Set table, click "Campaign ID Details" in the table to be taken back to the Data Set schema screen.

Click Get schema. You'll see something similar to the following:

CSV header
ga:campaignCode,ga:source,ga:medium

 

This is the header you should use as the first line of your uploaded CSV files. The table below identifies the columns:

Campaign ID Source Medium
ga:campaignCode ga:source ga:medium

2. Create a spreadsheet and export it as a CSV

Close the dialog and create a Google spreadsheet that follows the format. The first (header) row of your spreadsheet should use the internal names (e.g. ga:campaignCode) provided in the Get schema dialog as shown above. The columns beneath each header cell should include the corresponding data for each header.

ga:campaignCode ga:source ga:medium
123xyz Fall Newsletter email
567abc Spring Newsletter email

Export the spreadsheet as a CSV. Your file will look something like this:

ga:campaignCode,ga:source,ga:medium
123xyz,Fall Newsletter,email
567abc,Spring Newsletter,email

 

Step Five: Upload the data

You can must now upload the CSV file you created to Analytics. You have two choices for uploading your data: manually, using the Analytics user interface, or programmatically, using the Management API.

Upload manually
  1. In the Data Set table, find the row for the Campaign ID Details Data Set.

  2. Click Manage uploads for that Data Set.
  3. Click Upload file, select the CSV file you created, then click Upload.
Upload via the Management API
  1. In the Data Set table, find the row for Campaign ID Details.
  2. Click the data-set name.
  3. Click Get Custom Data Source ID
  4. Make a copy of the ID.
  5. Follow these instructions to upload via the Management API.

Once this information has been uploaded, Analytics will retrieve the Campaign ID from a URL's utm_id parameter, and then join the hit data with the Medium and Source that are associated with that particular Campaign ID. For example, if you upload the data file shown above, all the sessions with ?utm_id=567abc will have a Source of "Spring Newsletter" and a Medium of "email".

Step Six: See the data in reports

To see the data, go to the Acquisition > All Traffic or Acquisition > Channels report. Select Source, Medium, or Source/Medium as the Primary Dimension.

Uploaded data needs to be processed before it can show up in reports. Once processing is complete, it may take up to 24 hours before the imported data will begin to be applied to incoming hit data.

Was this helpful?

How can we improve it?
true
Choose your own learning path

Check out google.com/analytics/learn, a new resource to help you get the most out of Google Analytics 4. The new website includes videos, articles, and guided flows, and provides links to the Google Analytics Discord, Blog, YouTube channel, and GitHub repository.

Start learning today!

Search
Clear search
Close search
Google apps
Main menu
15882692339887892260
true
Search Help Center
true
true
true
true
true
69256
true
false