> For the complete documentation index, see [llms.txt](https://docs.expel.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.expel.io/more-features/expel-managed-phishing/setup-guides/enable-gmail-logs-in-bigquery.md).

# Enable Gmail Logs in BigQuery

The following procedure guides you through enabling logs for Gmail in BigQuery to make the most use of Expel Managed Phishing. For example, you can then run an [Investigative Action](/workbench-reference/expel-terminology.md#investigative-action) that identifies recipients of malicious emails.&#x20;

1. Sign in to the [Google Admin Console](https://admin.google.com/).
2. Navigate to **Apps > Google > Workspace > Gmail​ > Setup > Email Logs in BigQuery**.
3. Select the **Enable** checkbox and enter a **Description**, such as "Gmail logs".
4. Select the ‌**project** to which the service account belongs.
5. Enter "gmail\_logs\_dataset" as the name for the new BigQuery dataset and select **SAVE**.
6. From the IAM console in the project where the service account was created, select the **pencil** icon, then search for and add the **BigQuery Job User** role to the service account.

<figure><img src="/files/jnGB3ZoghworKpR8z0LP" alt=""><figcaption></figcaption></figure>

7. Select **SAVE**.
8. Navigate to [BigQuery in the Google Cloud console](https://console.cloud.google.com/bigquery).
9. Find the `gmail_logs_dataset`, then open the menu on the right and select **Open**.

<div align="left"><figure><img src="/files/zF9RHKSpuiLm2aCG2gfy" alt="" width="375"><figcaption></figcaption></figure></div>

10. From the dataset details, select **EDIT DETAILS**.
11. Change the **Default maximum table age** to **30 days** (Expel's recommendation).
12. Select **SAVE**.
13. Select **SHARING > Permissions**.

<div align="left"><figure><img src="/files/0GEH7CqEZcHEkI3QEOqt" alt="" width="563"><figcaption></figcaption></figure></div>

14. Under **New principals**, add the service account.
15. Select the `BigQuery Data Viewer` role.
16. Select **SAVE** to close the panel.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.expel.io/more-features/expel-managed-phishing/setup-guides/enable-gmail-logs-in-bigquery.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
