# Google Analytics on boxd

> Google Analytics tracks and reports website traffic, user behavior, and conversion data, enabling marketers to optimize online performance and customer journeys.

- Page: https://boxd.sh/integrations/google-analytics/
- CLI: `run google-analytics` (69 commands, 65 marked common)
- SDK: `import { googleAnalytics } from "@boxd/run"`; every parameter and response type is at `@boxd/run/google-analytics`
- Triggers: none
- Connect: `run auth google-analytics` (Sign in with Google Analytics), or https://app.boxd.sh/integrations/detail/google_analytics
- All integrations: https://boxd.sh/integrations/ (Markdown: https://boxd.sh/integrations/index.md)

## From the shell

```sh
run auth google-analytics      # once: prints a link to connect your account
run google-analytics           # list its commands
run google-analytics list-accounts-v1-beta
```

Parameters are flags (`--flag value`); object and array parameters take a JSON string. Output is YAML, or JSON with `--json`. Calls use your own connection; `--scope <name>` uses a connection shared with your team.

## From a script

```ts
import { every, googleAnalytics } from "@boxd/run";

every("1 hour", async () => {
  const result = await googleAnalytics.listAccountsV1Beta({});
  console.log(result);
});
```

Run it with `run google-analytics.run.ts`. Google Analytics has no triggers; `every()` polls on a schedule, keeps the script running as a job, and wakes the machine when it is due.

## Commands

Required flags are listed; `run google-analytics <command> --help` lists the optional ones. "common" marks what `run google-analytics` shows without `--all`.

| Command | SDK method | Required flags | Optional | Description |
|---|---|---|---|---|
| `archive-custom-dimension` | `googleAnalytics.archiveCustomDimension()` | `--name` | 0 | Archive a CustomDimension on a property |
| `batch-run-pivot-reports` ·common | `googleAnalytics.batchRunPivotReports()` | `--property` `--requests` | 0 | Return multiple pivot reports in a batch for a GA4 property |
| `batch-run-reports` ·common | `googleAnalytics.batchRunReports()` | `--property` `--requests` | 1 | Return multiple analytics data reports in a batch |
| `check-compatibility` ·common | `googleAnalytics.checkCompatibility()` | `--property` | 5 | List dimensions and metrics compatible with a GA4 report request |
| `create-audience-export` ·common | `googleAnalytics.createAudienceExport()` | `--audience` `--parent` | 1 | Create an audience export for Google Analytics |
| `create-audience-list` ·common | `googleAnalytics.createAudienceList()` | `--audience` `--dimensions` `--parent` | 1 | Create an audience list for later retrieval by initiating a long-running asynchronous request |
| `create-custom-dimension` ·common | `googleAnalytics.createCustomDimension()` | `--displayName` `--parameterName` `--parent` `--scope` | 2 | Create a CustomDimension for a Google Analytics property |
| `create-custom-metric` ·common | `googleAnalytics.createCustomMetric()` | `--displayName` `--measurementUnit` `--parameterName` `--parent` `--scope` | 2 | Create a custom metric in Google Analytics |
| `create-expanded-data-set` ·common | `googleAnalytics.createExpandedDataSet()` | `--expandedDataSet` `--parent` | 0 | Create an expanded data set for a property |
| `create-recurring-audience-list` ·common | `googleAnalytics.createRecurringAudienceList()` | `--audience` `--dimensions` `--parent` | 2 | Create a recurring audience list that automatically generates new audience lists daily based on the latest data |
| `create-report-task` ·common | `googleAnalytics.createReportTask()` | `--parent` | 1 | Create a report task as a long-running asynchronous request for customized Google Analytics event data reports |
| `create-rollup-property` ·common | `googleAnalytics.createRollupProperty()` | `--account` `--displayName` `--timeZone` | 1 | Create a roll-up property |
| `get-account` ·common | `googleAnalytics.getAccount()` | `--name` | 0 | Retrieve a single Account by its resource name |
| `get-attribution-settings` ·common | `googleAnalytics.getAttributionSettings()` | `--name` | 0 | Retrieve attribution configuration for a Google Analytics property |
| `get-audience` ·common | `googleAnalytics.getAudience()` | `--audienceId` `--propertyId` | 0 | Retrieve a single Audience configuration from a Google Analytics property |
| `get-audience-export` ·common | `googleAnalytics.getAudienceExport()` | `--name` | 0 | Get configuration metadata about a specific audience export |
| `get-audience-list` ·common | `googleAnalytics.getAudienceList()` | `--name` | 0 | Get configuration metadata about a specific audience list |
| `get-custom-dimension` ·common | `googleAnalytics.getCustomDimension()` | `--name` | 0 | Retrieve a single CustomDimension by its resource name |
| `get-data-retention-settings` ·common | `googleAnalytics.getDataRetentionSettings()` | `--name` | 0 | Retrieve data retention configuration for a Google Analytics property |
| `get-data-sharing-settings` ·common | `googleAnalytics.getDataSharingSettings()` | `--name` | 0 | Retrieve data sharing configuration for a Google Analytics account |
| `get-google-signals-settings` ·common | `googleAnalytics.getGoogleSignalsSettings()` | `--name` | 0 | Retrieve Google Signals configuration settings for a GA4 property |
| `get-key-event` ·common | `googleAnalytics.getKeyEvent()` | `--name` | 0 | Retrieve a Key Event |
| `get-metadata` ·common | `googleAnalytics.getMetadata()` | `--name` | 0 | Get metadata for dimensions, metrics, and comparisons for a GA4 property |
| `get-property` ·common | `googleAnalytics.getProperty()` | `--name` | 0 | Retrieve a single GA4 Property by its resource name |
| `get-property-quotas-snapshot` ·common | `googleAnalytics.getPropertyQuotasSnapshot()` | `--property` | 0 | Retrieve all property quotas organized by category (corePropertyQuota, funnelPropertyQuota, realtimePropertyQuota) for a given GA4 property |
| `get-recurring-audience-list` ·common | `googleAnalytics.getRecurringAudienceList()` | `--name` | 0 | Get configuration metadata about a specific recurring audience list |
| `get-report-task` ·common | `googleAnalytics.getReportTask()` | `--name` | 0 | Get report metadata about a specific report task |
| `list-account-summaries` ·common | `googleAnalytics.listAccountSummaries()` | — | 2 | Retrieve summaries of all Google Analytics accounts accessible by the caller |
| `list-accounts` ·common ·deprecated | `googleAnalytics.listAccounts()` | — | 3 | Use ListAccountsV1Beta instead |
| `list-accounts-v1-beta` ·common | `googleAnalytics.listAccountsV1Beta()` | — | 3 | List all Google Analytics accounts accessible by the caller using v1beta API |
| `list-adsense-links` ·common | `googleAnalytics.listAdsenseLinks()` | `--parent` | 2 | List all AdSenseLinks on a property |
| `list-audience-exports` ·common | `googleAnalytics.listAudienceExports()` | `--parent` | 2 | List all audience exports for a property |
| `list-audience-lists` ·common | `googleAnalytics.listAudienceLists()` | `--parent` | 2 | List all audience lists for a specified property to help find and reuse existing lists |
| `list-audiences` ·common | `googleAnalytics.listAudiences()` | `--parent` | 2 | List Audiences on a property |
| `list-bigquery-links` ·common | `googleAnalytics.listBigqueryLinks()` | `--parent` | 2 | List BigQuery Links on a property |
| `list-calculated-metrics` ·common | `googleAnalytics.listCalculatedMetrics()` | `--parent` | 2 | List Calculated Metrics |
| `list-channel-groups` ·common | `googleAnalytics.listChannelGroups()` | `--parent` | 2 | List ChannelGroups on a property |
| `list-conversion-events` ·common | `googleAnalytics.listConversionEvents()` | `--parent` | 2 | List conversion events on a property |
| `list-custom-dimensions` ·common | `googleAnalytics.listCustomDimensions()` | `--parent` | 2 | List Custom Dimensions |
| `list-custom-metrics` ·common | `googleAnalytics.listCustomMetrics()` | `--parent` | 2 | List CustomMetrics on a property |
| `list-data-streams` ·common | `googleAnalytics.listDataStreams()` | `--parent` | 2 | List DataStreams on a property |
| `list-dv360-ad-links` ·common | `googleAnalytics.listDv360AdLinks()` | `--parent` | 2 | List Display & Video 360 advertiser links on a property |
| `list-dv360-link-proposals` ·common | `googleAnalytics.listDv360LinkProposals()` | `--parent` | 2 | List DisplayVideo360AdvertiserLinkProposals on a property |
| `list-event-create-rules` | `googleAnalytics.listEventCreateRules()` | `--parent` | 2 | List EventCreateRules configured on a web data stream |
| `list-expanded-data-sets` ·common | `googleAnalytics.listExpandedDataSets()` | `--parent` | 2 | List ExpandedDataSets on a property |
| `list-firebase-links` ·common | `googleAnalytics.listFirebaseLinks()` | `--parent` | 2 | List FirebaseLinks on a property |
| `list-google-ads-links` ·common | `googleAnalytics.listGoogleAdsLinks()` | `--parent` | 2 | List GoogleAdsLinks on a property |
| `list-key-events` ·common | `googleAnalytics.listKeyEvents()` | `--parent` | 2 | List Key Events |
| `list-measurement-protocol-secrets` ·common | `googleAnalytics.listMeasurementProtocolSecrets()` | `--parent` | 2 | List MeasurementProtocolSecrets under a data stream |
| `list-properties` ·common ·deprecated | `googleAnalytics.listProperties()` | `--account` | 3 | Use ListPropertiesV1Beta instead |
| `list-properties-filtered` ·common | `googleAnalytics.listPropertiesFiltered()` | `--filter` | 3 | List GA4 properties based on filter criteria |
| `list-recurring-audience-lists` ·common | `googleAnalytics.listRecurringAudienceLists()` | `--parent` | 2 | List all recurring audience lists for a GA4 property |
| `list-report-tasks` ·common | `googleAnalytics.listReportTasks()` | `--parent` | 2 | List all report tasks for a Google Analytics property |
| `list-reporting-data-annotations` ·common | `googleAnalytics.listReportingDataAnnotations()` | `--parent` | 3 | List all Reporting Data Annotations for a specific property |
| `list-search-ads360-links` ·common | `googleAnalytics.listSearchAds360Links()` | `--parent` | 2 | List all SearchAds360Links on a property |
| `list-sk-ad-network-conversion-value-schemas` | `googleAnalytics.listSkAdNetworkConversionValueSchemas()` | `--parent` | 2 | List SKAdNetworkConversionValueSchema configurations for an iOS data stream |
| `list-subproperty-event-filters` | `googleAnalytics.listSubpropertyEventFilters()` | `--parent` | 2 | List all subproperty event filters on a property |
| `list-subproperty-sync-configs` ·common | `googleAnalytics.listSubpropertySyncConfigs()` | `--parent` | 2 | List SubpropertySyncConfig resources for managing subproperty synchronization configurations |
| `provision-account-ticket` ·common | `googleAnalytics.provisionAccountTicket()` | `--account` `--redirectUri` | 0 | Request a ticket for creating a Google Analytics account |
| `query-audience-export` ·common | `googleAnalytics.queryAudienceExport()` | `--name` | 2 | Query a completed audience export |
| `query-audience-list` ·common | `googleAnalytics.queryAudienceList()` | `--name` | 2 | Query an audience list |
| `query-report-task` ·common | `googleAnalytics.queryReportTask()` | `--name` | 2 | Retrieve a report task's content |
| `run-funnel-report` ·common | `googleAnalytics.runFunnelReport()` | `--funnel` `--property` | 8 | Run a GA4 funnel report |
| `run-pivot-report` ·common | `googleAnalytics.runPivotReport()` | `--metrics` `--property` | 10 | Run a customized pivot report of Google Analytics event data |
| `run-realtime-report` ·common | `googleAnalytics.runRealtimeReport()` | `--property` | 9 | Run a customized realtime report of Google Analytics event data |
| `run-report` ·common | `googleAnalytics.runReport()` | `--property` | 15 | Run a customized GA4 data report |
| `send-events` ·common | `googleAnalytics.sendEvents()` | `--api-secret` `--client-id` `--events` `--measurement-id` | 4 | Send event data to Google Analytics 4 using the Measurement Protocol |
| `update-property` ·common | `googleAnalytics.updateProperty()` | `--name` `--updateMask` | 6 | Update an existing GA4 Property |
| `validate-events` ·common | `googleAnalytics.validateEvents()` | `--api-secret` `--client-id` `--events` `--measurement-id` | 4 | Validate Measurement Protocol events before sending them to production |

## Docs

- [run CLI](https://docs.boxd.sh/cli/run): Call connected integrations from the shell, connect new ones, and run automations.
- [Quickstart](https://docs.boxd.sh/guides/integrations/quickstart): Connect an integration, call it from the shell, and turn a script into an automation.
- [Connections](https://docs.boxd.sh/guides/integrations/connections): Connect an account once, for yourself or for your whole organization.
- [Scripts](https://docs.boxd.sh/guides/automations/scripts): Typed integrations, triggers, schedules and state in a .run.ts file.
- [Jobs](https://docs.boxd.sh/guides/automations/jobs): How a script becomes a background job: states, retries, sleep and wake.
- [Beyond the catalog](https://docs.boxd.sh/guides/automations/beyond-the-catalog): Reach your own APIs, databases and cloud accounts from a script.
