Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recipe google analytics #22648

Merged
merged 24 commits into from
Apr 7, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
de5db9d
Update deploying-your-site.md
jeffpascal Mar 29, 2020
72f8a98
Added link from recipes page
jeffpascal Mar 29, 2020
64a1a41
chore: format
Mar 30, 2020
5bd2af2
Update docs/docs/recipes/deploying-your-site.md
jeffpascal Apr 7, 2020
8494fba
Update docs/docs/recipes/deploying-your-site.md
jeffpascal Apr 7, 2020
8ca13df
Update docs/docs/recipes/deploying-your-site.md
jeffpascal Apr 7, 2020
69292b5
Update docs/docs/recipes/deploying-your-site.md
jeffpascal Apr 7, 2020
26fd509
Update docs/docs/recipes/deploying-your-site.md
jeffpascal Apr 7, 2020
c9a35a4
Update docs/docs/recipes/deploying-your-site.md
jeffpascal Apr 7, 2020
6118325
Update docs/docs/recipes/deploying-your-site.md
jeffpascal Apr 7, 2020
5d492ac
Update docs/docs/recipes/deploying-your-site.md
jeffpascal Apr 7, 2020
211b0b4
Update docs/docs/recipes/deploying-your-site.md
jeffpascal Apr 7, 2020
31767a6
Update docs/docs/recipes/deploying-your-site.md
jeffpascal Apr 7, 2020
9eaf976
Update docs/docs/recipes/deploying-your-site.md
jeffpascal Apr 7, 2020
e4ddca6
Update docs/docs/recipes/deploying-your-site.md
jeffpascal Apr 7, 2020
bb9b690
Update docs/docs/recipes/deploying-your-site.md
jeffpascal Apr 7, 2020
3f5856e
Update docs/docs/recipes/deploying-your-site.md
jeffpascal Apr 7, 2020
f9dd2f1
Update docs/docs/recipes/deploying-your-site.md
jeffpascal Apr 7, 2020
07d4231
Update docs/docs/recipes/deploying-your-site.md
jeffpascal Apr 7, 2020
e074c01
Update docs/docs/recipes/deploying-your-site.md
jeffpascal Apr 7, 2020
a6c9f34
Update docs/docs/recipes/deploying-your-site.md
jeffpascal Apr 7, 2020
fa725e7
Update deploying-your-site.md
jeffpascal Apr 7, 2020
84b9ac4
chore: format
Apr 7, 2020
f67fddc
Minor formatting, finishing step
Apr 7, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/docs/recipes.md
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,4 @@ Showtime. Once you are happy with your site, you are ready to go live with it!
- [Deploying to Netlify](/docs/recipes/deploying-your-site#deploying-to-netlify)
- [Deploying to ZEIT Now](/docs/recipes/deploying-your-site#deploying-to-zeit-now)
- [Deploying to Cloudflare Workers](/docs/recipes/deploying-your-site#deploying-to-cloudflare-workers)
- [Setting up Google Analytics](/docs/recipes/deploying-your-site#setting-up-google-analytics)
56 changes: 56 additions & 0 deletions docs/docs/recipes/deploying-your-site.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,59 @@ Use [`wrangler`](https://developers.cloudflare.com/workers/tooling/wrangler/) to
### Additional resources

- [Hosting on Cloudflare](/docs/deploying-to-cloudflare-workers)

## Setting up Google Analytics

Use `gatsby-plugin-google-analytics` to track site activity and provide insights into how users access your website.

### Prerequisites

- A [Gatsby site](/docs/quick-start) with a `gatsby-config.js` file and an `index.js` page
- The [Gatsby CLI](/docs/gatsby-cli) installed
- A domain from your provider of choice, e.g. [AWS](https://aws.amazon.com/getting-started/tutorials/get-a-domain/)

### Verify the domain in search.google.com

1. Navigate to the [Google search console](<(https://search.google.com/search-console/not-verified)>) to verify the domain by clicking on **Search Property** > **Add Property**. Type in your domain and press Continue.
2. Add a **TXT** record to your DNS configuration. Follow the directions for your provider, or refer to the [Google documentation](https://support.google.com/a/answer/183895?hl=en).

### Linking the domain to Google Analytics admin

1. Log into [Google Analytics](https://analytics.google.com/analytics/).
2. Click **Admin**.
3. Select **Create Property** in the Property column.
4. Choose **Web**.
5. Fill in the details and click **Create**.

### Getting your Google Analytics `Tracking ID`

1. Sign in to your Google Analytics account.
2. Click **Admin**.
3. Select an account from the menu in the ACCOUNT column.
4. Select a property from the menu in the PROPERTY column.
5. Under Property, click **Tracking Info** > **Tracking Code**. Your Tracking ID is displayed at the top of the page.

### Using the ID in the plugin

1. Run `npm install gatsby-plugin-google-analytics` in your terminal.
2. Add the following to your `gatsby-config.js` file.

```javascript:title="gatsby-config.js"
module.exports = {
plugins: [
{
resolve: `gatsby-plugin-google-analytics`,
options: {
// replace "UA-XXXXXXXXX-X" with your own Tracking ID
trackingId: "UA-XXXXXXXXX-X",
},
},
],
}`
```

3. Build and deploy your site to start seeing traffic in your [Google Analytics dashboard](https://analytics.google.com/analytics/web/).

### Additional resources

- [adding-analytics](https://www.gatsbyjs.org/docs/adding-analytics/)