Set Up GA4 Cost Data Imports Over Secure FTP

Set Up GA4 Cost Data Imports Over Secure FTP

If you've recently migrated your Google Analytics accounts from Universal Analytics to Google Analytics 4, you might be wondering how to import your cost data into GA4. Power My Analytics makes it easy to import your historical cost data to GA4 over secure FTP, and set up a schedule for your cost imports to stay updated with new data every day.

We know the transition to Google Analytics 4 is a top priority for our customers, especially those using cost data imports in Universal Analytics. Power My Analytics is ready to help you make the switch with an easy-to-follow setup process. This article will show you how to set up secure FTP access to your cost data and run an initial backfill of your historical data into GA4 then configure a scheduled daily refresh in order to keep your imported cost data up to date.

At this time, only one cost data source can be imported to your GA4 property. For example, you can import cost data either from Facebook Ads only or from Microsoft Ads only, but not from both at once. We are currently working on a solution to support multiple cost data imports into GA4 from more than one source.

You Will Need:

  1. The GA4 property you wish to use as a destination for your cost data.
  2. An FTP server with secure FTP (SFTP). Google Analytics 4 will only use SFTP and will not use unsecured FTP. If you have questions about setting up secure FTP, please contact your server administrator for assistance.
  3. Your FTP server hostname, username, and password.

Create a New Report in Your Hub 

The first step is to create a report to backfill your historical cost data into GA4. To do this, you'll need to:
  1. Create an initial template report to specify the data account you want to use.
  2. Then create a cost data report from the template report.
Later, you can come back and change the settings on the cost data report so it refreshes with new data every day.

Start at hub.powermyanalytics.com. Under Reports, go to Data Explorer. Then click + Add Report to start creating the template report. 



Under Report Name, make sure to give your report a name like "DO NOT USE - Microsoft Advertising", since this will be the initial report that's only used as a template, and not the cost data report you'll be exporting to GA4.



In this example, under Connector, we’ll select Microsoft Advertising.



Under Data Account, select the data account you want to use as a source for your cost data. Make sure to select the correct data account, or GA4 will not be able to retrieve your cost data.



In Configure, select any configuration settings, then click Set Config.



Under Date Range, select the timespan of historical data you'd like to backfill. In this example, we’ll select the last 90 days of data. 

Google Analytics 4 only allows a historical backfill of up to 90 days of data. This is a limitation of GA4's cost imports.

Select Last X days, then enter 90 and click Set.





Then click Set Range.



Under Fields, click the Select fields… text field.



When you’re setting up a report for cost imports, you don’t need to know the exact fields for your connector. PMA will set those up for you in the next step automatically.
You can enter any field, or enter “date” to choose the date field.



Then click Set Fields.



If you don't need to add a filter, you can just click Set Filter to continue.



Under Options, select a field to Order By, and choose an ascending or descending order. In this example, we’ll sort by date in ascending order.





Set the Limit to 1000000 to make sure the report captures all of your historical data.



Go back to the top of the page and click Save.



Your new template report will appear under Reports in the Data Explorer. Now it's time to create your cost data report from the template report. Next to the report, click the green Create Template Report button on the right.



The Template Report menu will appear next to your report, and you can select Cost Imports from the dropdown.



Click Report Group to select the group in which you'd like your report to be placed.



Click the red Confirm button to continue.



Your cost data report is created, and all of your metrics and dimensions for GA4 will be populated and configured automatically according to the connector you've chosen.

You can confirm that the fields have been added correctly by going to the report group you chose and clicking the pencil icon to edit the cost imports report for your connector.



Your cost imports fields for the connector will be visible under Fields.



Make sure to remember the name of this report, as you will need it when setting up FTP exports in the next step. This report will automatically be given a name similar in style to microsoft_ads_cost_imports.

Schedule a New FTP Export in Your Hub

Next, set up an export of your historical data backfill from PMA to your FTP server.

In your hub under Exports, click on FTPClick on the + Create Export button.



Next to Destination, click the blue + to add a destination.



Under FTP type, select SFTP, for Secure FTP.


Under Server Name, enter a name like "Cost imports server" to label your server. This can be any name that you choose for your own reference, and it is not the same thing as the server hostname. Under Host, enter your server hostname, then enter your FTP Username and Password. Power My Analytics will always keep your credentials encrypted and securely stored. 



Then click Connect. Under Destination, select the name of the FTP server you just created.


Under File format, select CSV.



In the Directory path field, enter the path for the directory on your server you’d like to use for your CSV exports. This might be a path like /home/demo/reports. Then click Next.



Next, under Report or Report group, select Single report.



For Report, select the name of the cost report that you created using the report template.



Then click Next.



Finally, under Schedule, set the refresh period to Monthly, because you only want to backfill your historical data once.



Under Refresh on, you can select the 1st or any day of the month.



For Hour, select 5:00.



Click Add, then click Confirm, and your FTP export will be configured.





Then find your new export in the list under Exports, and click the play arrow button to run the export now.



Your export will start running and uploading your historical data to your FTP server.



You can click View Logs to see the status of your FTP export. 





Make sure your export finishes running before you begin setting up your cost import in GA4.

Set Up Your Cost Data Import in GA4

Now it’s time to configure your cost imports from your FTP exports in Google Analytics 4. Make sure you've set up the GA4 property you want to use as a data destination. After you’ve set up your data source and imported your historical data, your cost import in GA4 will continue to update with new data every day from your FTP server.

Go to analytics.google.com to get started. Click on the gear icon in the lower left corner to open your Admin settings and navigate to the property you'd like to use.



Under your property, click on Data Import



Click the Create data source button.



Under Data source name, enter a name for your cost import like "Microsoft Advertising cost import 1". Under Data type, make sure Cost data is selected.



Scroll down to Upload data for import, and select SFTP.



In SFTP server username, enter your username to log in to your FTP server.



Make sure you know the path and filename for the export on your FTP server. If your sftp protocol URL is not formatted correctly, GA4's import will fail.

Under SFTP server url, enter the URL for the CSV file containing your cost data. This URL will need to be in the sftp protocol format, which looks like this:
sftp://[hostname]:22//[directory path]/[cost data filename].csv
You can also obtain this URL by installing the free FileZilla FTP client. Follow FileZilla's instructions to log in to your server with your FTP hostname, username and password. The root directory of your FTP server will appear in the right panel.



Then navigate to the directory you entered as the path for your FTP exports, and find the exported CSV file.



Right-click on the file and select Copy URL(s) to clipboard.



This will copy a URL in a format similar to:
sftp://[username]@[hostname]/home/demo/reports/Microsoft_Advertising_-_Account_1.csv
Before entering the URL into GA4, make sure to:
  1. Remove [username]@ from the URL
  2. Add :22 after [hostname] to use secure FTP port 22
  3. Place a second / before the leading / for the directory path
Your URL should look like this when you enter it into GA4:
sftp://[hostname]:22//home/demo/reports/Microsoft_Advertising_-_Account_1.csv



You can leave the SFTP key comment field blank.

Then select the schedule. Make sure Frequency is set to Daily, and select a Start time of 6:00 AM - 7:00 AM.



The start time must be at least an hour later than the hour selected for your scheduled FTP export. This will ensure that your cost data has finished exporting to your FTP server by the time GA4 is scheduled to retrieve it. 
Click the blue Next button in the upper right corner to continue.



Now you can set up the field mapping for your cost data imports. Under Import field for each row, click the pencil icon and enter the column names for:
  1. Campaign ID
  2. Campaign source
  3. Campaign medium
  4. Campaign name
  5. Date




Then check the box for each metric you’re using, and enter the import field name for each metric.
GA4 requires you to select at least one metric.



Power My Analytics provides a list of these mappings for you to use for 12 of our connectors, and we’re adding more all the time. See our full list of supported connectors and their fields for GA4 cost data and their imports for more information.

Next, click Create & generate key.



Google Analytics 4 will provide a public key for you to copy and authorize on your FTP server.



Save a copy of this key and follow your server administrator’s instructions to authorize it on your server.
Then click Done.


Start Your Import

Now you can view your import under Data Import in the GA4 admin section.



Click Import now in the row for your data source to begin importing your cost data.





Your import will start processing, and in a few minutes, you can see whether your cost data was imported successfully.

Schedule a Daily Refresh of Your Import

Now that your historical data is imported, you can go back to your Power My Analytics hub and set up a daily refresh of your cost data. This will keep your GA4 cost import data updated every day with new data from your FTP export.

First, change the report to include the last 7 days of data instead of the last 90 days. In your hub, go to Data Explorer and find your report in the Reports table. Click the pencil icon to edit that report. 
Make sure you're editing the correct cost data report, not the initial template report. This should be the same report you created from the template when setting up your FTP export earlier. You may need to look under Group to find your report in another group of reports.



Click on Date Range and select Last 7 days.



Then click Set Range.



Click the blue Save button to save your changes. 



Your report is now updated. Next, change the FTP export to refresh every day.

Click on FTP under ExportsFind your export in the Exports table and click the pencil icon to edit the settings.



Click on Reports, and then click on Schedule to skip to the schedule settings. Change the refresh period to Daily.



Keep Hour on the previous setting to make sure the FTP export will finish running every day before GA4 retrieves this data. Then click the blue Update button.



Click on the Confirm button.



Your new schedule settings will be saved, and your report will be exported to your FTP server every day at 5:00 AM Eastern time (America/New York).



Your cost import over FTP is ready, and GA4 will continue importing your new data every day.

    Still having issues?
    Send us a ticket and we will get back to you.
      • Related Articles

      • GA4 Cost Import Field Mapping

        When setting up cost imports with PMA in Google Analytics 4, each of our supported connectors has its own set of field mappings that must be manually entered. This is a limitation of GA4. In this article, we'll show you which field names to use for ...
      • How to Create an FTP Export

        FTP can be a valuable way for Enterprise users to export their Data Explorer reports. In this article, we will walk you through creating an FTP export, including selecting an FTP destination, scheduling data refreshes, and managing your exports to ...
      • How Does PMA Secure My Data?

        Many of our clients are understandably invested in the security of their data and their clients' data. This article will show you how Power My Analytics keeps all of your warehoused data safe and secure. Where does the data go? Power My Analytics ...
      • Sample Data Guide

        Sample Data is an innovative offering from Power My Analytics. This guide will dive into the details of the Sample Data, its value, and how to use it. It covers two primary topics: The Value of Sample Data, and How to Use Sample Data. The Value of ...
      • Choose a Data Destination

        Not sure where to begin with making reports or having trouble deciding which reporting tool will be best for your business? Let us help! This article will tell you what you need to know about which reporting options are available with your plan and ...