# Manual Analytics Uploads https://api-docs.lumar.io/docs/graphql/manual-analytics-uploads If you can't connect an analytics account to a project, or want to add data from another tool, you can upload the figures as CSV files instead. A crawl that includes the **Analytics** source (`GoogleAnalytics` crawl type) reads every enabled analytics upload in the project. It matches each uploaded URL to the crawled pages and fills in the same metrics a connected analytics account would. By default the crawl also crawls every URL in the uploaded files. To add metrics only to pages the crawl finds from its other sources, see [Data only](#data-only). This page covers the two general-purpose analytics upload types: | Upload type | `projectUploadType` | What it adds | | ------------------- | ------------------- | ------------------------------------------------------------------------------ | | Analytics | `AnalyticsCSV` | Sessions, bounce rate, time on page, pageviews and conversions per URL | | AI Referral Sources | `AIReferralSources` | Sessions, users, views and bounce rate per URL **and** per referring AI source | Other analytics types are built around the export formats of specific tools: - `GoogleAnalyticsCSV`, for the legacy Universal Analytics "Landing Pages" export. For data from Google Analytics 4, use `AnalyticsCSV`. - `AdobeAnalyticsCSV` and `ReducedAdobeAnalyticsCSV`, for Adobe Analytics report exports. - `AdwordsFinalUrlCSV`, for the Google Ads final URL report. Clicks are stored as sessions and impressions as pageviews. They follow the same file rules, but the first three start reading data further down the file, so they ignore some rows (see [Where data starts](#where-data-starts)). Prefer `AnalyticsCSV` with renamed columns. `getUrlFileUploadTypes` returns the headers and starting row each type expects (see [Customizing the column mapping](#customizing-the-column-mapping)). ## Uploading a file Uploads use the two-step flow described in [Create URL File Upload](create-url-file-upload): `createSignedUrlFileUpload` returns a pre-signed URL, and you `PUT` the file to it within 15 minutes. For analytics files, set `crawlTypeCode` to `GoogleAnalytics` and `projectUploadType` to the upload type: ```graphql mutation CreateAiReferralSourcesUpload($input: CreateSignedUrlFileUploadInput!) { createSignedUrlFileUpload(input: $input) { signedS3UploadUrl urlFileUpload { id fileName status } } } ``` **Variables:** ```json { "input": { "projectId": "TjAwN1Byb2plY3QxMjM0NQ", "crawlTypeCode": "GoogleAnalytics", "projectUploadType": "AIReferralSources", "fileName": "ai-referrals.csv" } } ``` The file name must end in `.csv`. Once the file is processed, the upload's `status` is `Processed` and `totalRows` holds the number of rows read. If processing fails, the status is `Errored` and `errorMessage` says why: ```graphql query GetAnalyticsUploads($projectId: ObjectID!) { getProject(id: $projectId) { urlFileUploads(first: 50) { nodes { id fileName enabled status totalRows errorMessage urlFileUploadType { code } } } } } ``` **Variables:** ```json { "projectId": "TjAwN1Byb2plY3QxMjM0NQ" } ``` **Response:** ```json { "data": { "getProject": { "urlFileUploads": { "nodes": [ { "id": "TjAxM1VybEZpbGVVcGxvYWQ0MjMxOQ", "fileName": "analytics.csv", "enabled": true, "status": "Processed", "totalRows": 1840, "errorMessage": null, "urlFileUploadType": { "code": "AnalyticsCSV" } }, { "id": "TjAxM1VybEZpbGVVcGxvYWQ0MjMyMA", "fileName": "ai-referrals.csv", "enabled": true, "status": "Processed", "totalRows": 212, "errorMessage": null, "urlFileUploadType": { "code": "AIReferralSources" } } ] } } } } ``` ## File format The rules below apply to both upload types. - **The first line is the header row.** Header names are matched case-insensitively, and column order doesn't matter. Extra columns are ignored. Exports that start with comment or title lines, such as the `#` lines at the top of a Google Analytics 4 CSV export, need those lines removed first. - **Every header in the upload type's template must be present.** A file that is missing one fails with `
metric key not found`, even if you have no data for that column. Keep the column and leave its cells empty, or [customize the column mapping](#customizing-the-column-mapping). - **Cells may be empty.** An empty cell is stored as no value, not zero. - **Every row needs a URL.** Rows with an empty or invalid URL are skipped. URLs can be absolute or relative to the upload's `uploadBaseDomain`, which defaults to the project's primary domain. - **Each row must have as many cells as the header row.** Rows that don't are skipped without failing the file, so check `totalRows` against your row count. - Separate values with commas, and wrap a value that contains a comma in double quotes, for example `"1,234"`. ### Where data starts Each upload type's template has a `data_start_row`: the line of the first data row, counting the header as line 1. The header is always read from the first line of the file, and data rows before `data_start_row` are ignored. `AnalyticsCSV` and `AIReferralSources` use `2`, so every row after the header is read. A few legacy types use a higher value, written for exports with title lines above the header: `GoogleAnalyticsCSV` uses `8`, `AdobeAnalyticsCSV` `28` and `ReducedAdobeAnalyticsCSV` `27`. Because the header is still read from line 1, neither layout works fully with them: - Uploaded as exported, with the title lines, the file's first title line is read as the header. The data rows don't match it, so no rows are imported, and the upload still reports `Processed`. - With the title lines removed, the first `data_start_row - 2` data rows are ignored. For `GoogleAnalyticsCSV` that's the first 6 rows. Use `AnalyticsCSV` instead, with the export's columns renamed to its headers, or upload with a [custom column mapping](#customizing-the-column-mapping) that sets `data_start_row` to `2`. ### Value types Each column is read as one of these value types. A value that doesn't fit its type is stored as no value; the file doesn't fail. | Type | Accepted values | Example | | --------- | ------------------------------------------------------------------------ | ----------------- | | `integer` | Whole numbers; thousands separators are removed | `1,234` → `1234` | | `decimal` | Plain numbers; thousands separators are removed, nothing else is allowed | `0.4235` | | `percent` | Numbers with or without a trailing `%` | `42.5%` or `42.5` | | `time` | Durations in `hh:mm:ss`, with two digits in each part | `00:01:35` | | `string` | Any text, stored as-is | `chatgpt.com` | ## Analytics (`AnalyticsCSV`) | Header | Type | Notes | | --------------------------------- | --------- | ---------------------------------------------------------------------------------------------------------- | | `url` | `string` | The page URL | | `visits` | `integer` | Sessions for the page (see below) | | `load time` | `decimal` | Average page load time | | `bounce rate` | `percent` | For example `42.5%`. GA4 exports a fraction such as `0.425`: multiply it by 100, or it is stored as 0.425% | | `time on page` | `time` | Average time on page, `hh:mm:ss`. GA4 exports seconds: convert them, or the value is stored empty | | `pages per visit` | `decimal` | Pageviews per session | | `pageviews` | `integer` | | | `primary conversions count` | `integer` | Leave empty if you don't track conversions | | `primary conversions per session` | `decimal` | Leave empty if you don't track conversions | | `primary conversions value` | `decimal` | Leave empty if you don't track conversions | ```csv url,visits,load time,bounce rate,time on page,pages per visit,pageviews,primary conversions count,primary conversions per session,primary conversions value https://www.example.com/,5120,1.8,38.2%,00:01:12,2.4,12288,,, /blog/getting-started,"1,204",2.1,51%,00:02:47,1.6,1926,,, ``` **What to count as visits.** Lumar doesn't check how the sessions were counted. A connected Google Analytics 4 account reports sessions that viewed the page when it imports all traffic, and landing-page sessions when it imports a single channel such as organic search. Either definition works in an upload. Use the same one in every file so crawls stay comparable. ## AI Referral Sources (`AIReferralSources`) Each row holds the traffic one AI source sent to one page, so a URL appears once for each source that referred visitors to it. | Header | Type | Notes | | ---------------- | --------- | --------------------------------------------------------- | | `url` | `string` | The landing page URL | | `Session Source` | `string` | The referring source, see [Source values](#source-values) | | `Sessions` | `integer` | Sessions that started on this page from this source | | `Total users` | `integer` | | | `Views` | `integer` | | | `Bounce rate` | `decimal` | A fraction, as GA4 exports it: `0.4235`, not `42.35%` | ```csv url,Session Source,Sessions,Total users,Views,Bounce rate https://www.example.com/pricing,chatgpt.com,184,160,231,0.4130 https://www.example.com/pricing,perplexity.ai,37,35,52,0.3784 https://www.example.com/blog/ai-search,gemini.google.com,12,12,15,0.5000 ``` **What to count as sessions.** Count landing-page sessions per source, which is what Lumar imports from a connected Google Analytics 4 account (sessions by landing page and session source). This upload type is the file equivalent of that import. **Bounce rate** is a `decimal`, unlike the Analytics upload's `percent`. A value with a `%` sign is stored as no value. ### Source values Use the source exactly as Google Analytics 4 reports it in the `Session source` dimension: the referrer's lowercase hostname. Lumar groups these values into platforms: | `Session Source` value | Platform | | -------------------------------------- | ------------------ | | `chatgpt.com`, `chat.openai.com` | ChatGPT / OpenAI | | `claude.ai` | Claude / Anthropic | | `gemini.google.com`, `bard.google.com` | Google (Gemini) | | `copilot.microsoft.com` | Microsoft Copilot | | `perplexity.ai`, `perplexity` | Perplexity | Matching is exact and case-sensitive. Any other value, including `ChatGPT` or `https://chatgpt.com`, is still imported and counts towards the page's AI referral totals, but it is grouped under **Other**. The per-platform reports only list pages with one specific source value: | Report | Source value it looks for | | ---------------------------------------- | ------------------------- | | Pages with ChatGPT Referring Sessions | `chatgpt.com` | | Pages with Claude Referring Sessions | `claude.ai` | | Pages with Gemini Referring Sessions | `gemini.google.com` | | Pages with Perplexity Referring Sessions | `perplexity.ai` | ### GEO custom metrics AI Referral Sources uploads are used only in crawls of projects that have the **GEO** custom metric container. The upload type lists it in `requiredContainerNames`. Without the container, the crawl leaves the upload out without reporting an error. ## Using several uploads in one crawl A project can have any number of analytics uploads. Every crawl that includes the Analytics source reads **every enabled upload** in the project, so an Analytics upload and an AI Referral Sources upload can both feed the same crawl. File names don't matter: the upload type chosen when the upload was created decides how a file is read. Uploads stay enabled for later crawls until you disable or delete them. To keep an upload but leave it out of future crawls, set `enabled` to `false`: ```graphql mutation DisableUpload($input: UpdateUrlFileUploadInput!) { updateUrlFileUpload(input: $input) { urlFileUpload { id enabled } } } ``` **Variables:** ```json { "input": { "urlFileUploadId": "TjAxM1VybEZpbGVVcGxvYWQ0MjMxOQ", "enabled": false } } ``` If the project also has a connected Google Analytics 4 account, an AI Referral Sources upload and the GA4 import are combined. Where both have figures for the same URL and source, the uploaded figures are used. ### Data only Adding `GoogleAnalytics` to a project's `crawlTypes` makes every URL in its analytics uploads a crawl start point as well as a source of metrics. To add metrics only to pages the crawl finds from its other sources, also add `GoogleAnalytics` to `dataOnlyCrawlTypes`. The project then needs another source that supplies URLs, such as `Web`. Both lists replace the project's current values, so send every source you want to keep: ```graphql mutation SetAnalyticsDataOnly($input: UpdateProjectInput!) { updateProject(input: $input) { project { id crawlTypes dataOnlyCrawlTypes } } } ``` **Variables:** ```json { "input": { "projectId": "TjAwN1Byb2plY3QxMjM0NQ", "crawlTypes": ["Web", "GoogleAnalytics"], "dataOnlyCrawlTypes": ["GoogleAnalytics"] } } ``` The `GoogleAnalytics` source is shared with the Google Analytics 4 and Adobe Analytics integrations, so this setting applies to them too. ## Customizing the column mapping When your file uses different headers, or lacks some columns, you can give the upload its own column mapping instead of editing the file. Each upload type's `uploadTemplate` maps a Lumar metric to a CSV header and a value type, and `data_start_row` gives the line where data starts, counting the header as line 1 (`2` means straight after the header row; see [Where data starts](#where-data-starts)): ```graphql query GetAnalyticsUploadTypes { getUrlFileUploadTypes { code name requiredContainerNames uploadTemplate } } ``` **Response:** ```json { "data": { "getUrlFileUploadTypes": [ { "code": "AIReferralSources", "name": "AI Referral Sources", "requiredContainerNames": ["GEO"], "uploadTemplate": { "data_start_row": 2, "metrics": { "url": { "header": "url", "type": "string" }, "ga_session_source": { "header": "Session Source", "type": "string" }, "ga_sessions": { "header": "Sessions", "type": "integer" }, "ga_total_users": { "header": "Total users", "type": "integer" }, "ga_screen_page_views": { "header": "Views", "type": "integer" }, "ga_bounce_rate": { "header": "Bounce rate", "type": "decimal" } } } }, { "code": "AnalyticsCSV", "name": "Analytics", "requiredContainerNames": null, "uploadTemplate": { "data_start_row": 2, "metrics": { "url": { "header": "url", "type": "string" }, "sessions": { "header": "visits", "type": "integer" }, "avg_page_load_time": { "header": "load time", "type": "decimal" }, "bounce_rate": { "header": "bounce rate", "type": "percent" }, "avg_time_on_page": { "header": "time on page", "type": "time" }, "pageviews_per_session": { "header": "pages per visit", "type": "decimal" }, "pageviews": { "header": "pageviews", "type": "integer" }, "primary_conversions_count": { "header": "primary conversions count", "type": "integer" }, "primary_conversions_per_session": { "header": "primary conversions per session", "type": "decimal" }, "primary_conversions_value": { "header": "primary conversions value", "type": "decimal" } } } } ] } } ``` Pass a modified copy as `uploadTemplate` when you create the upload, or as `customUploadTemplate` in `updateUrlFileUpload` later. Keep the metric keys, change the `header` values to match your file, and set `header` to `null` for a metric your file doesn't have. Lumar then doesn't look for that column. This upload reads a file whose sessions are in a `sessions` column and whose URLs are in `landing page`, without load time or conversion columns: ```graphql mutation CreateAnalyticsUploadWithoutConversions($input: CreateSignedUrlFileUploadInput!) { createSignedUrlFileUpload(input: $input) { signedS3UploadUrl urlFileUpload { id fileName status } } } ``` **Variables:** ```json { "input": { "projectId": "TjAwN1Byb2plY3QxMjM0NQ", "crawlTypeCode": "GoogleAnalytics", "projectUploadType": "AnalyticsCSV", "fileName": "analytics.csv", "uploadTemplate": { "data_start_row": 2, "metrics": { "url": { "header": "landing page", "type": "string" }, "sessions": { "header": "sessions", "type": "integer" }, "avg_page_load_time": { "header": null, "type": "decimal" }, "bounce_rate": { "header": "bounce rate", "type": "percent" }, "avg_time_on_page": { "header": "time on page", "type": "time" }, "pageviews_per_session": { "header": "pages per visit", "type": "decimal" }, "pageviews": { "header": "pageviews", "type": "integer" }, "primary_conversions_count": { "header": null, "type": "integer" }, "primary_conversions_per_session": { "header": null, "type": "decimal" }, "primary_conversions_value": { "header": null, "type": "decimal" } } } } } ``` A customized upload keeps its original upload type's behaviour, including the GEO requirement for AI Referral Sources, and keeps it when you send a new `customUploadTemplate` later. To change the type as well, send `projectUploadType` with the template. A template that doesn't match this structure is rejected with `URL_FILE_UPLOAD_UPLOAD_TEMPLATE_INVALID`.