> ## Documentation Index
> Fetch the complete documentation index at: https://www.twicecommerce.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# How to connect Looker Studio to TWICE Commerce

> Build Looker Studio dashboards on your TWICE Commerce revenue and payments data, loaded through a Google Sheet that refreshes on a timer.

<Frame caption="Reports > Sales overview > Export">
  <img src="https://mintcdn.com/twicecommerce/Ab7tx7ih94KQsi0k/images/reports-export.webp?fit=max&auto=format&n=Ab7tx7ih94KQsi0k&q=85&s=5b8746adc8bb592f174ae9f8130924e2" alt="The Export tab of a report, with the REST API endpoints" width="1920" height="1080" data-path="images/reports-export.webp" />
</Frame>

<Card title="Open in TWICE Admin" icon="external-link" href="https://admin.twicecommerce.com/reports" horizontal>
  reports
</Card>

Load the ledgers into a Google Sheet, then add the sheet's two tabs to Looker Studio as data sources. Looker Studio has no connector that sends an API key header, so the sheet is the bridge.

## Prerequisites

<Warning>
  **Required access:** a TWICE Commerce API key, used by the Google Sheet. Anyone who can edit the sheet can read the key, so give Looker Studio viewers access to the dashboard only. See [API keys](/docs/concepts/integrations/api-keys).
</Warning>

<Info>
  **Before you start:** set up the sheet in [Connect Google Sheets](/docs/guides/reports/connect-google-sheets) and let the script run once, so the `Revenue` and `Payments` tabs hold data.
</Info>

## The walkthrough

<Steps>
  <Step title="Add the revenue tab as a data source">
    In Looker Studio, choose **Create → Data source** and pick the **Google Sheets** connector. Select your spreadsheet and the `Revenue` worksheet, keep **"Use first row as headers"** on, and select **Connect**.
  </Step>

  <Step title="Check the field types">
    Set `Create_Date`, `Start_Date` and `End_Date` to **Date**, and every `Amount_` field to **Currency** in your currency. Set `Row_ID` and `Order_ID` to **Text**.
  </Step>

  <Step title="Add the payments tab">
    Repeat the two steps for the `Payments` worksheet, with `Payment_Date` as **Date**.
  </Step>

  <Step title="Blend when a chart needs both">
    Add a blend with `Payments` on the left and `Revenue` on the right, joined as a left outer join on `Revenue_Row_ID` = `Row_ID`. Use the blend only where a chart needs fields from both ledgers.
  </Step>

  <Step title="Set the data freshness">
    Open the data source, choose **Data freshness**, and set it to match the sheet's trigger. A daily script needs no more than an hourly check.
  </Step>
</Steps>

## How do I know it worked?

* A scorecard summing `Amount_Total`, filtered to `Started_In_Period` = `Yes`, matches the **Revenue report** in the admin for the same period and currency.
* After the sheet's next scheduled run, the dashboard shows the new rows without editing the data source.

## Troubleshooting / common pitfalls

<AccordionGroup>
  <Accordion title="Amounts sum to zero or show as text">
    The field was detected as **Text**. Set it to **Currency** in the data source. If it keeps reverting, the sheet holds text in that column: check that the sheet's script wrote numbers.
  </Accordion>

  <Accordion title="A field disappears after a refresh">
    The tax columns follow the tax rates in the period, so `Tax_Rate_2` can come and go. Build charts on `Amount_Excl_Tax` and `Amount_Total`, and select **Refresh fields** on the data source when the tax columns change.
  </Accordion>

  <Accordion title="The dashboard shows yesterday's numbers">
    The sheet refreshes only when its trigger runs. Run `refreshTwiceLedgers` in Apps Script for a manual update, or add a second daily trigger.
  </Accordion>
</AccordionGroup>

Google documents the connector in [Connect to Google Sheets](https://docs.cloud.google.com/looker/docs/studio/connect-to-google-sheets) and freshness in [Manage data freshness](https://docs.cloud.google.com/looker/docs/studio/manage-data-freshness).

## Related articles

<CardGroup cols={2} className="doc-rows-condensed">
  <Card title="Connect Google Sheets" href="/docs/guides/reports/connect-google-sheets">
    The sheet this dashboard reads.
  </Card>

  <Card title="Pull your data into a BI tool" href="/docs/guides/reports/pull-report-data">
    The endpoints, the file format and the data model.
  </Card>

  <Card title="Finance reports" href="/docs/concepts/reports/finance-reports">
    Every ledger column, and how each number is derived.
  </Card>
</CardGroup>
