# Connect GitHub to StoreScope Analytics

> Views, unique visitors, clones, stars and where developers come from, per repository.

## What it unlocks in StoreScope Analytics

- Views, unique visitors, clones, stars, top referring sites and popular paths, per repository you add to an app.

## The access it needs

| For | Least role or permission |
|---|---|
| Traffic (views, clones, referrers, paths) | Administration: Read-only |
| Stars and repository totals | Metadata: Read-only (always included) |

- Choose Only select repositories and pick the ones you track. For an organisation's repositories, the resource owner is the organisation, which may have to approve the token.
- A token that reads a repository but not its traffic still brings stars and totals; traffic stays empty until the token has Administration read.

## Steps

1. Create a fine-grained token with read-only access to the repositories you want tracked: Administration (read) for traffic, Metadata (read). [New fine-grained token](https://github.com/settings/personal-access-tokens/new)
2. Add the repositories to each app on the Apps page (owner/name).
3. In StoreScope Analytics, open Connections, choose GitHub, fill in the form and save. The connection is checked live with the store first; a connection that fails the check is never saved.

## What the form asks for

- Token (required)

## Errors the check can show

The exact sentence the Connections page shows (<angle brackets> are your own values), then what to do.

- "Token is required."
  Paste the token GitHub showed when you created it.
- "That does not look like a GitHub token."
  Copy the whole token (github_pat_…), with no spaces.
- "GitHub refused the token (401): it is wrong, expired or revoked."
  Create a new token and paste it.
- "GitHub answered: <message>"
  GitHub's own message says what is wrong (often a rate limit; try again later).

Errors any connection can show: https://storescope.devino.ca/docs/connect.md
