Introduction
The Linking API provides a reliable interface to configure and forward users directly to a Data Studio report via a URL. When users follow a Linking API URL they will have a streamlined experience to quickly view and interact with their data.
This document describes the required format of Linking API URLs and the available parameters.
Use case and benefits
The Linking API can be used to provide pre-configured reports for your customers to view and interact with their data. Key benefits of the Linking API are as follows:
- A one-click report creation experience for your customers.
- The data configuration is provided in the URL so users don't need to configure the report for their data.
- Users can save the report with a single click and revisit the report at any time.
- Create reports at scale. The Linking API reduces the time required to duplicate or create new reports.
- Enable product integrations. The stable interface allows you to integrate Data Studio into a product workflow.
How it works
The following describes how developers and users interact with the Linking API.
Linking API developer workflow
The developer prepares the template reports, data sources, and formats a Linking API URL. The typical workflow for developers is as follows:
- Decide whether to use a blank report, the default report template provided by Data Studio or create a Data Studio report that will serve as a template. This includes configuring the template data sources.
- Format a Linking API URL for your specific use case. If applicable, specify the report template and other parameters, including the report name, data source name and data source configurations.
- Use the Linking API URL to direct users to the report.
Linking API user experience
The user follows a Linking API URL, that if configured correctly by the developer, will direct them to a Data Studio report that allows them to view and interact with data they have access to. A typical user experience may be as follows:
- In a browser, the user visits a service that has integrated with the Linking API.
- A call to action invites the user to click a link to view their data in Data Studio.
- The user follows the link and is directed to a Data Studio report. The report loads and the user is able to view and interact with their data.
- The user clicks “Edit and share”. The report is saved to their Data Studio account.
- The user now has full access and control over their own copy of the report. They can view, edit and share at any time.
Requirements
To ensure a Linking API URL works as expected, the following is required:
- A report, to serve as a template. If not provided then a blank report or default report, provided by Data Studio, can be used.
- Users of a Linking API URL must have, at a minimum, view access to the template report. Depending on the type of data sources used in the report and the configuration provided via the Linking API, users may also require view access to data sources. See Template permissions for details.
- The Connector type of each data source must support configuration via the Linking API. Refer to the Connector reference for a list of supported connectors.
- Users of the Linking API URL must have access to the data configured in the Linking API URL. If the user does not have access to the underlying data, any dependent report components will show an error.
URL parameters
A Linking API URL must be of the following form:
https://datastudio.google.com/reporting/create?parameters
The URL is expected to be used in the context of a web browser, typically by a user clicking on a link or being redirected to the URL. It can also be used to Embed a report.
Example URL
The following is an example Linking API URL. The report name is set and a single BigQuery data source is configured:
https://datastudio.google.com/reporting/create?
c.reportId=12345
&r.reportName=MyNewReport
&ds.ds0.connector=bigQuery
&ds.ds0.datasourceName=MyNewDataSource
&ds.ds0.projectId=project-1234
&ds.ds0.type=TABLE
&ds.ds0.datasetId=456
&ds.ds0.tableId=789
Certain URL parameters are required, while some are optional. The following is a list of parameters used to define a Linking API URL:
Control parameters
Control parameters determine the state of the report when viewed via the Linking API URL.
| Parameter name | Description |
|---|---|
| Optional. The template Report ID. Data Studio will open and configure the report specified. For details on how to find the ID, see Report ID. If unspecified, a blank report or default report template is used, see Use a blank or default report for details. | |
| Optional. The ID of the initial page to load in the report. Defaults to the first page of the report if unspecified, . | |
Optional. The initial report mode. One of
view or
edit. Defaults to view if unspecified.
|
|
Optional. The visibility of the info/debug dialog. Set to
true to show the dialog button. Defaults to
false if unspecified. See
Troubleshooting configuration issues to learn more.
|
Example
https://datastudio.google.com/reporting/create?
c.reportId=12345
&c.pageId=g7u8s9
&c.mode=edit
&r.reportName=MyNewReport
&ds.ds0.datasourceName=MyNewDataSource
&ds.ds0.connector=bigQuery
&ds.ds0.projectId=project-1234
&ds.ds0.type=TABLE
&ds.ds0.datasetId=456
&ds.ds0.tableId=789
Report parameters
Report parameters override report properties.
| Parameter name | Description |
|---|---|
| Optional. Sets the report name. If unspecified, defaults to the template report name. | |
|
Optional. Sets the Google Analytics Measurement IDs to Measure report usage. Use a comma to separate multiple IDs. If |
|
|
Optional. Set to If |
Example
https://datastudio.google.com/reporting/create?
c.reportId=12345
&r.reportName=MyNewReport
&r.measurementId=G-XXXXXXXXXX
&ds.ds0.datasourceName=MyNewDataSource
&ds.ds0.connector=bigQuery
&ds.ds0.projectId=project-1234
&ds.ds0.type=TABLE
&ds.ds0.datasetId=456
&ds.ds0.tableId=789
Data source parameters
Data source parameters allow you to define a data source configuration and the data to access for data sources in the template report.
An alias is used to reference a data source in an existing report. Using an
alias allows for backwards compatibility if a data source is added/removed from
the template report.
For details on how to find a data source alias, see Data source alias.
Data source parameters
The following parameters are common across all connector types:
| Name | Description |
|---|---|
|
Optional. Sets the name of the data source. If |
|
|
Optional. Set to If |
|
|
Optional.
The connector type of the data source. For more information on supported connector types, see the Connector reference. If set then all required connector parameters for the connector type must be specified in the Linking API URL and the template data source configuration will be replaced in its entirety. If unspecified, then zero or more connector parameters for the connector type can be specified in the Linking API URL. The template data source configuration will be used to specify any parameters not provided in the Linking API URL. For details on how to identify the connector type of the template data source, see Connector type. To learn more about how the |
|
|
Optional.
Set to Set to If unspecified, defaults vary by connector type. Review the Connector reference for connector specific defaults in case you want to override the default behavior. Considerations when using
refreshFields:
|
|
| Required. The data source configuration for the connector type. For details on how to identify the connector used to create a data source, see Connector type. For details on the data source parameters available for each connector type, see the Connector reference. |
Replace vs update - Data source configurations
When setting data source parameters, the presence or omission of the
ds.connector parameter in the Linking API URL indicates the
intention to replace or update the template data source configuration,
respectively.
The following table details how the ds.connector parameter affects whether a
template data source configuration is replaced in its entirety or used to update
unspecified parameters:
Is ds.connector set? |
Expected configuration and behavior | Typical use |
|---|---|---|
| Yes |
Replace. The template data source configuration is replaced in its
entirety, using the data source parameters specified in the Linking
API URL. You must specify all required parameters for the
connector type. See Required parameters when
ds.connector is set.
|
|
| No | Update. The template data source configuration will be used to
specify any parameters not provided in the Linking API URL. All connector
parameters for the connector type are optional, unless otherwise stated.
This simplifies the Linking API URL and is generally recommended when you are familiar with the template data source configuration and only want to override a subset of parameters. |
|
Required parameters when ds.connector is set
If a data source's ds.connector parameter is specified, then
all connector parameters designated as Required must be specified for the
data source. If the data source's ds.connector parameter is
unspecified, then all connector parameters, even those designated as required,
can be treated as optional, unless otherwise stated.
Examples
Configures a report with a single BigQuery data source (ds0) and replaces the
data source configuration in its entirety:
https://datastudio.google.com/reporting/create?
c.reportId=12345
&r.reportName=MyNewReport
&ds.ds0.datasourceName=MyNewDataSource
&ds.ds0.connector=bigQuery
&ds.ds0.type=TABLE
&ds.ds0.projectId=bigquery-public-data
&ds.ds0.datasetId=samples
&ds.ds0.tableId=shakespeare
The data source alias can be omitted when the report has a single data source. The URL above can be simplified to the following:
https://datastudio.google.com/reporting/create?
c.reportId=12345
&r.reportName=MyNewReport
&ds.datasourceName=MyNewDataSource
&ds.connector=bigQuery
&ds.type=TABLE
&ds.projectId=bigquery-public-data
&ds.datasetId=samples
&ds.tableId=shakespeare
Configures a report with a single BigQuery data source (ds0) and
updates only the billing project ID of the
data source:
https://datastudio.google.com/reporting/create?
c.reportId=12345
&r.reportName=MyNewReport
&ds.ds0.billingProjectId=my-billing-project
Configures a report with two data sources, a BigQuery data source (ds0) and a
Google Analytics data source (ds1). The BigQuery data source configuration is
replaced in its entirety, while the Google Analytics configuration updates a
single parameter and relies on the ds1 template data source for any
unspecified connector parameters:
https://datastudio.google.com/reporting/create?
c.reportId=7890
&r.reportName=MyNewReportWithMultipleDataSources
&ds.ds0.datasourceName=MyNewDataSource
&ds.ds0.connector=bigQuery
&ds.ds0.type=TABLE
&ds.ds0.projectId=bigquery-public-data
&ds.ds0.datasetId=samples
&ds.ds0.tableId=shakespeare
&ds.ds1.viewId=92320289
Create vs Add
It can sometimes be useful to have the same data source in multiple reports so updates to the data source affect all reports together. When creating a report with the Linking API, you can re-add a datasource from your template report by ensuring all the following conditions are met:
- The data source is reusable (see embedded vs reusable data sources)
- The url does not reference the data source by alias
- The url does not use a wildcard alias (see Data source alias wildcard)
When a new data source is created with the Linking API, it uses the credentials of the user that clicked the url. That means the user must have access to the underlying data or the connection won't work. By re-adding the data source to the newly generated report, you can preserve its credentials so users can continue accessing data in their new reports.
Data source alias wildcard
To apply a Linking API parameter to multiple data sources, the wildcard alias
ds.* can be used in place of the data source alias.
This can be useful for removing repetitive parameters from your url. For
example, if you have a template with three BigQuery data sources attached, and
you want to replace the projectId and datasetId in
each one, but preserve the tableId, you could write it as:
https://datastudio.google.com/reporting/create?
c.reportId=7890
&ds.ds1.projectId=client-project
&ds.ds1.datasetId=client-dataset
&ds.ds2.projectId=client-project
&ds.ds2.datasetId=client-dataset
&ds.ds3.projectId=client-project
&ds.ds3.datasetId=client-dataset
Or, with the ds.* wildcard, you can use this equivalent url:
https://datastudio.google.com/reporting/create?
c.reportId=7890
&ds.*.projectId=client-project
&ds.*.datasetId=client-dataset
Parameters provided to the Linking API that don't use the ds.* wildcard are
given precedence over ones that are. In the example above, you can add a
specific datasource alias to override the value from the wildcard.
https://datastudio.google.com/reporting/create?
c.reportId=7890
&ds.*.projectId=client-project
&ds.*.datasetId=client-dataset
&ds.ds1.datasetId=client-dataset
More generally, the order of parameter precedence is:
- A parameter given with specific alias (
ds.ds1.datasetId) - A parameter provided using the wildcard (
ds.*.datasetId) - A value derived from the template datasource, if ds.connector is not provided (see Replace vs update)
- The default value for the parameter, if it is optional.
Connector reference
The Linking API supports the following connectors and configurations. For each connector, the list of available data source parameters is provided.
BigQuery
The BigQuery connector supports two types of queries, a TABLE query, in which
you provide the Table ID of the table to query and a CUSTOM_QUERY, in which
you provide a SQL statement to query a table.
TABLE queries
The following parameters are applicable when type is set to TABLE and you
provide the ID of the table to query.
| Parameter name | Description |
|---|---|
Optional. Set to bigQuery for the
BigQuery
connector.If set, replaces the data source with the provided BigQuery configuration. See Replace vs update. |
|
Required** The type of query. Set to
TABLE. |
|
| Required** The Project ID of the table to query. | |
| Required** The Dataset ID of the table to query. | |
| Required** The Table ID of the table to
query. Date sharded tables: The * (wildcard character) or YYYYMMDD suffix is supported
when querying date sharded tables.If a table is identified as Google Analytics, Firebase Analytics, or Firebase Crashlytics, a default fields template will be selected unless one is specified. See the fields template table related parameters. |
|
Optional. The ID of the Project to use for billing. If not set,
projectId will be used. |
|
Optional. Set to true if the table is partitioned and you
want to use the partitioning column as a date range dimension. This is
only applicable to time based partitioning (E.g. using a time based
partitioning column or the _PARTITIONTIME pseudocolumn) and
does not work for integer range partitioned tables. Defaults to
false if unspecified. To learn more see
Introduction to partitioned tables. |
|
Optional. Defaults to true if unspecified. See
refreshFields for details. |
Fields template for Google Analytics, Firebase Analytics and Crashlytics
For tables identified as Google Analytics, Firebase Analytics, or Firebase Crashlytics, additional parameters are available to set the fields template. If unspecified, a default template will be selected.
| Name | Description |
|---|---|
Optional. The Google Analytics fields template to use. Applicable only
when a BigQuery export for Google Analytics table is being queried. One
of ALL, SESSION, HITS. For Google
Analytics tables, defaults to ALL if unspecified. |
|
Optional. The Firebase Analytics fields template to use. Applicable
only when a BigQuery export for Firebase Analytics table is being queried.
Can only be set to EVENTS. For Firebase Analytics tables,
defaults to EVENTS if unspecified. |
|
The Firebase Crashlytics fields template to use. Can only be set to
DEFAULT. Applicable only when a BigQuery export for Firebase
Crashlytics table is being queried. For Firebase Crashlytics tables,
defaults to DEFAULT if unspecified. |
CUSTOM queries
The following parameters are applicable when type is set to CUSTOM_QUERY and
you provide a SQL statement to query a table.
| Parameter name | Description |
|---|---|
Optional. Set to bigQuery for the
BigQuery
connector.If set, replaces the data source with the provided BigQuery configuration. See Replace vs update. |
|
Required** The type of query. Set to
CUSTOM_QUERY. |
|
| Required** The SQL query to run. | |
Optional. The ID of the Project to use for billing. If not set,
projectId will be used. If projectId is not set
then the project of the queried table will be used. |
|
|
Optional. A comma-delimited list of pattern and replacement strings to
apply to the SQL query. String replacement is only applied if there is a
pattern match. Use a comma to separate pattern and replacement string
pairs. For example, |
|
Optional. Defaults to true if unspecified. See
refreshFields for details. |
Examples
A TABLE type configuration where the query is defined with a Table ID:
https://datastudio.google.com/reporting/create?
c.reportId=123abc
&ds.ds0.connector=bigQuery
&ds.ds0.type=TABLE
&ds.ds0.projectId=bigquery-public-data
&ds.ds0.datasetId=samples
&ds.ds0.tableId=shakespeare
&ds.ds0.billingProjectId=myProject
A TABLE type configuration to query a date sharded table using the wildcard
character suffix:
https://datastudio.google.com/reporting/create?
c.reportId=123abc
&ds.ds0.connector=bigQuery
&ds.ds0.type=TABLE
&ds.ds0.projectId=price-data
&ds.ds0.datasetId=samples
&ds.ds0.tableId=stock_*
A TABLE type configuration to query a date sharded table using the YYYYMMDD
suffix:
https://datastudio.google.com/reporting/create?
c.reportId=123abc
&ds.ds0.connector=bigQuery
&ds.ds0.type=TABLE
&ds.ds0.projectId=price-data
&ds.ds0.datasetId=samples
&ds.ds0.tableId=stock_YYYYMMDD
A TABLE type configuration to query a BigQuery Export for Google Analytics
table, using the SESSION fields template:
https://datastudio.google.com/reporting/create?
c.reportId=123abc
&ds.ds0.connector=bigQuery
&ds.ds0.type=TABLE
&ds.ds0.projectId=my-gabq-project
&ds.ds0.datasetId=1234567
&ds.ds0.tableId=ga_sessions_YYYYMMDD
&ds.ds0.gaTemplateLevel=SESSION
A TABLE type configuration to query an ingestion time partitioned table and
use the partitioning column as a date range dimension:
https://datastudio.google.com/reporting/create?
c.reportId=123abc
&ds.ds0.connector=bigQuery
&ds.ds0.type=TABLE
&ds.ds0.projectId=acme-co-logs
&ds.ds0.datasetId=logs
&ds.ds0.tableId=logs_table
&ds.ds0.isPartitioned=true
A CUSTOM_QUERY type configuration where they query is defined with a SQL
statement:
https://datastudio.google.com/reporting/create?
c.reportId=123abc
&ds.ds0.connector=bigQuery
&ds.ds0.type=CUSTOM_QUERY
&ds.ds0.projectId=bigquery-public-data
&ds.ds0.sql=SELECT%20word%2C%20word_count%20FROM%20%60bigquery-public-data.samples.shakespeare%60
&ds.ds0.billingProjectId=myProject
A CUSTOM_QUERY type configuration where only the SQL statement is updated and
the template data source is used for the rest of the configuration:
https://datastudio.google.com/reporting/create?
c.reportId=123abc
&ds.ds0.sql=SELECT%20corpus%20FROM%20%60bigquery-public-data.samples.shakespeare%60
A CUSTOM_QUERY type configuration where the SQL statement of the template data
source is updated using sqlReplace:
https://datastudio.google.com/reporting/create?
c.reportId=123abc
&ds.ds0.sqlReplace=bigquery-public-data,new-project,samples,new-dataset
# The following shows a template query before and after sqlReplace is applied.
#
# Template data source custom query:
# SELECT word, word_count FROM big-query-public-data.samples.shakespeare
# INNER JOIN
# SELECT word, word_count FROM big-query-public-data.samples.raleigh
#
# New data source custom query with sqlReplace applied:
# SELECT word, word_count FROM new-project.new-dataset.shakespeare
# INNER JOIN
# SELECT word, word_count FROM new-project.new-dataset.raleigh
Cloud Spanner
| Parameter name | Description |
|---|---|
Optional. Set to cloudSpannerfor the
Cloud
Spanner connector.If set, replaces the data source with the provided Cloud Spanner configuration. See Replace vs update. |
|
| Required** The Project ID. | |
| Required** The instance ID. | |
| Required** The Database ID. | |
| Required** The SQL query to run. | |
Optional. Defaults to true if unspecified.
See refreshFields for details. |
Example
A Cloud Spanner configuration with a SQL statement:
https://datastudio.google.com/reporting/create?
c.reportId=456def
&ds.ds1.connector=cloudSpanner
&ds.ds1.projectId=myProject
&ds.ds1.instanceId=production
&ds.ds1.datasetId=transactions
&ds.ds1.sql=SELECT%20accountId%2C%20date%2C%20revenue%20FROM%20sales%3B
Community Connectors
| Parameter name | Description |
|---|---|
Optional. Set to community for a
Community Connector.If set, replaces the data source with the provided Community Connector configuration. See Replace vs update. |
|
Required** The Community Connector
connectorId (also known as a deploymentId).
| |
| Optional. Additional connector-specific parameters, as defined by the community connector's connector configuration. | |
Optional. Defaults to true if unspecified. See
refreshFields for details. |
Example
Connect to a community connector with state and city configuration
parameters:
https://datastudio.google.com/reporting/create?
c.reportId=161718pqr
&ds.ds5.connector=community
&ds.ds5.connectorId=AqwqXxQshl94nJa0E0-1MsZXQL0DfCsJIMWk7dnx
&ds.ds5.state=CA
&ds.ds5.city=Sacramento
Google Analytics
| Parameter name | Description |
|---|---|
Optional. Set to googleAnalytics for the
Google
Analytics connector.If set, replaces the data source with the provided Google Analytics configuration. See Replace vs update. |
|
| Required** The Account ID. | |
| Required** The Property ID. | |
| The View ID. Required** for Universal Analytics properties. Do not set for Google Analytics 4 properties. |
|
Optional. Defaults to false if unspecified. See
refreshFields for details. |
Examples
A Google Analytics configuration for a Universal Analytics property:
https://datastudio.google.com/reporting/create?
c.reportId=789ghi
&ds.ds2.connector=googleAnalytics
&ds.ds2.accountId=54516992
&ds.ds2.propertyId=UA-54516992-1
&ds.ds2.viewId=92320289
A Google Analytics configuration for a Google Analytics 4 property:
https://datastudio.google.com/reporting/create?
c.reportId=789ghi
&ds.ds2.connector=googleAnalytics
&ds.ds2.accountId=54516992
&ds.ds2.propertyId=213025502
Google Cloud Storage
| Parameter name | Description |
|---|---|
Optional. Set to googleCloudStorage
Google
Cloud Storage connector.If set, replaces the data source with the provided Google Cloud Storage configuration. See Replace vs update. |
|
Required** The path type. Use
FILE to select a single file or FOLDER to select
all files for the given path. |
|
Required** The file path (e.g.
MyBucket/MyData/MyFile.csv) if pathType is
FILE or the folder path (e.g. *MyBucket/MyData) if
pathType is FOLDER. |
|
Optional. Defaults to true if unspecified.
See refreshFields for details. |
Example
A Google Cloud Storage configuration for a single file:
https://datastudio.google.com/reporting/create?
c.reportId=231908kpf
&ds.ds50.connector=googleCloudStorage
&ds.ds50.pathType=FILE
&ds.ds50.path=MyBucket%2FMyData%2FMyFile.csv
A Google Cloud Storage configuration for all files in the path:
https://datastudio.google.com/reporting/create?
c.reportId=231908kpf
&ds.ds50.connector=googleCloudStorage
&ds.ds50.pathType=FOLDER
&ds.ds50.path=MyBucket%2FMyData
Google Sheets
| Parameter name | Description |
|---|---|
Optional. Set to googleSheets for the
Google
Sheets connector.If set, replaces the data source with the provided Google Sheets configuration. See Replace vs update. |
|
| Required** The spreadsheet ID. | |
| Required** The worksheet ID. | |
Optional. Set to true to use the first row as headers.
Defaults to true if unspecified. Column headers must be
unique. Columns with empty headers will not be added to the data source.
|
|
Optional. Set to true to include hidden cells.
Defaults to true if unspecified. |
|
Optional. Set to true to include filtered cells.
Defaults to |