> For the complete documentation index, see [llms.txt](https://help.littledata.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.littledata.io/google-analytics/setup/import-data-into-ga4-external-shopify-app-cost-example.md).

# Import Data into GA4: External Shopify App Cost Example

GA4 tracks visits and sales from every channel, but it only knows the cost of Google Ads. If you pay for other channels, you can import their cost into GA4 and see their return on ad spend (ROAS). This page walks through an example using the cost of the Tapcart app..

### Why import cost data

GA4 cost data import lets you upload costs from platforms that don't connect to GA4 natively, like Meta Ads, Shop app ads, TikTok Ads or an external Shopify app. GA4 then matches that cost to the sessions, key events and revenue it already has for that source and medium. You can use it to compare ROAS across all your channels.

The import also works backwards in time, so you can add cost to traffic that GA4 has already recorded.

{% hint style="info" %}
The Littledata GA4 connection can attribute revenue to orders from external Shopify apps like Tapcart. You can also set your own source/medium rules by sales channel. See [Source/Medium customization](https://help.littledata.io/integrations/shopify-to-google-analytics/source-medium-customization-payment-gateway).
{% endhint %}

For Meta Ads, see [Import Meta Ads cost to Google Analytics](https://help.littledata.io/google-analytics/setup/import-meta-ads-cost-ga4).

### Understanding External Data Import in GA4

GA4’s cost data import allows you to upload costs incurred on platforms that don’t have a native integration with GA4, such as Facebook Ads, ShopApp Ads, TikTok Ads or any other channel. In this example we’ll focus on importing the cost of Tapcart App, so we can analyze the profitability of that channel.

Note that Littledata GA4 integration allows you to [properly attribute revenue in GA4](https://blog.littledata.io/2025/01/10/how-session-enrichment-improves-attribution-for-google-analytics/) to an external Shopify App (such as Tapcart). You can import cost data for a good ol' Facebook campaign as well, applying the method that will be described in the following text.

### Fields you can import

Google's [data import help article](https://support.google.com/analytics/answer/10071305?hl=en) includes a [CSV template for cost data](https://storage.googleapis.com/support-kms-prod/JpPxHIMgrGwbAmMxPu5AyvQs48IpsFrsNB6l). The column names define what you can import:

| Column         | What it holds                                         | Required?          |
| -------------- | ----------------------------------------------------- | ------------------ |
| source         | The traffic source, for example Tapcart, meta, tiktok | Yes                |
| medium         | The medium, for example cpc, paid\_video, display     | Yes                |
| date           | The day the cost happened, as YYYY-MM-DD              | Yes                |
| campaign\_id   | Campaign ID                                           | No                 |
| campaign\_name | Campaign name, for example spring\_sale               | No                 |
| impressions    | Daily impressions                                     | One of these three |
| clicks         | Daily clicks                                          | One of these three |
| cost           | Daily cost                                            | One of these three |

Source, medium and date must always be mapped. You also need to map at least one of cost, clicks or impressions:

![](https://3956158252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QhTbrMraNWciQeDvu1b%2Fuploads%2Fgit-blob-1870caa4c05b91a28ffe7862a05bc745f0f650bf%2Fat-least-one-field-obligatory.jpg?alt=media\&token=302c3d4d-9662-45a3-93c5-fef4c919afe4)

### Prepare your CSV file

Here is an example file for Tapcart, with dates in the right format:

| campaign\_id | campaign\_name        | source  | medium      | date       | impressions | clicks | cost |
| ------------ | --------------------- | ------- | ----------- | ---------- | ----------- | ------ | ---- |
| tid123       | tapcart\_cost\_import | Tapcart | Tapcart App | 2024-12-22 | 400         | 50     | 100  |
| tid124       | tapcart\_cost\_import | Tapcart | Tapcart App | 2024-12-23 | 500         | 60     | 110  |
| tid125       | tapcart\_cost\_import | Tapcart | Tapcart App | 2024-12-24 | 600         | 70     | 115  |
| tid126       | tapcart\_cost\_import | Tapcart | Tapcart App | 2024-12-25 | 550         | 55     | 95   |
| tid127       | tapcart\_cost\_import | Tapcart | Tapcart App | 2024-12-26 | 450         | 65     | 105  |
| tid128       | tapcart\_cost\_import | Tapcart | Tapcart App | 2024-12-27 | 650         | 40     | 90   |

Before you upload, check these common problems:

* **Date format.** Dates must be YYYY-MM-DD. Google's template and spreadsheet apps can use another format, like 12/22/2024. Fix this before you upload. If that happens, the import fails with "Invalid date detected":

![](https://3956158252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QhTbrMraNWciQeDvu1b%2Fuploads%2Fgit-blob-b26d8dd5bd747f49abfd347e6c21517b3d387867%2Ferror-invalid-date.jpg?alt=media\&token=2f0922ae-cd90-4779-a008-44964d750e0e)

* **Missing columns.** Keep all column headers, even if you have no data for a metric.
* **Source/medium mismatch.** The source and medium must match exactly what GA4 reports for that traffic. A small typo means the cost won't match any sessions, and it's hard to spot.

### Create the data source in GA4

{% stepper %}
{% step %}

### Open Data import

In GA4, go to **Admin** > **Data collection and modification** > **Data import**.<br>

![](https://3956158252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QhTbrMraNWciQeDvu1b%2Fuploads%2Fgit-blob-10b9fdab683a59f0b05bf9c49b79b98d785c51cc%2Fadmin-data-import.jpg?alt=media\&token=a98ffb58-ac34-433b-b830-f38aa5a39ac8)
{% endstep %}

{% step %}

### Create a cost data source

Click **Create data source**. Name your data source, choose **Cost data**, upload your CSV file and click **Next**.

![](https://3956158252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QhTbrMraNWciQeDvu1b%2Fuploads%2Fgit-blob-bce1dfe81ff4d152e634d43e56448598a71acdc2%2Fgif-for-csv.gif?alt=media\&token=22185240-6391-454b-bd85-dad64018a276)
{% endstep %}

{% step %}

### Map the fields

Match each column in your file to a GA4 field. Map source, medium and date, plus at least one of cost, clicks or impressions.
{% endstep %}

{% step %}

### Import

Click **Import**.
{% endstep %}
{% endstepper %}

### Fix common import errors

| Error                   | Fix                                                                                            |
| ----------------------- | ---------------------------------------------------------------------------------------------- |
| Invalid date detected   | Change the dates in your CSV to YYYY-MM-DD and upload again.                                   |
| Missing required field  | Check that every column header is included and spelled correctly, even if the column is empty. |
| Duplicate data detected | Don't upload the same data twice for the same date range.                                      |
| File formatting issue   | Save the file as CSV UTF-8 (comma-separated value                                              |

### Analyze the imported data

Once the import succeeds, you can see the cost data in GA4 next to your purchase data.

{% stepper %}
{% step %}

### Create an exploration

In GA4, go to **Explore** and create a new free-form exploration.
{% endstep %}

{% step %}

### Add the dimension

Add **Session source/medium** as a dimension.
{% endstep %}

{% step %}

### Add the non-Google cost metrics

Search for "non" in the metrics list and add the Non-Google metrics you need, along with metrics like Purchases and Gross purchase revenue.

![](https://3956158252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QhTbrMraNWciQeDvu1b%2Fuploads%2Fgit-blob-8c39753a2ea42e8474361a64cb4fb8f07a850eaf%2Fnon-g-ads-metrics.jpg?alt=media\&token=a226f921-050f-4679-b8dc-f86445030c3b)
{% endstep %}
{% endstepper %}

In this example, the store gets revenue from the Tapcart app at a very high return:

![](https://3956158252-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F1QhTbrMraNWciQeDvu1b%2Fuploads%2Fgit-blob-806bfd87867b9ccc171dac925e7790df3b33fed2%2Froas-of-tapcart.jpg?alt=media\&token=47331476-fd6c-4712-830f-fb101a683659)

In GA4, we see the high performing Tapcart channel:

* just above 2,700 purchases from this app
* close to $215,000 revenue generated
* External cost data imported correctly and it shows an astonishing ROAS of 344!

By importing ad cost data, GA4 now calculates ROAS (Revenue / Ad Spend) directly in reports, allowing better budget allocation and performance evaluation for non-Google ad platforms.

### Related articles

* [Import Meta Ads cost to Google Analytics](https://help.littledata.io/google-analytics/setup/import-meta-ads-cost-ga4)
* [How to calculate ROAS in GA4](https://help.littledata.io/google-analytics/acquisition/how-to-calculate-roas-in-ga4)
* [Source/Medium customization](https://help.littledata.io/integrations/shopify-to-google-analytics/source-medium-customization-payment-gateway)
* [Track Shopify sales channels in GA4](https://help.littledata.io/google-analytics/acquisition/how-to-track-shopify-sales-channels-in-ga4)
