> For the complete documentation index, see [llms.txt](https://ispectra.gitbook.io/mutamad/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://ispectra.gitbook.io/mutamad/site-building/analytics.md). Agents can also search and read this documentation through its [MCP server](https://ispectra.gitbook.io/mutamad/~gitbook/mcp).

# Analytics

Google Analytics with a dashboard in Arabic, held back until the visitor agrees.

`mutamad_analytics` adds Google Analytics 4 through **GA4 Dashboard**, a drupal.org module by the same team.

{% hint style="danger" %}
**Not applied by default.** Sending visits to Google is a transfer of personal data outside the Kingdom (PDPL Art. 29). Apply it only once the entity's data protection officer accepts it. Matomo on the entity's own server is the in-Kingdom alternative.
{% endhint %}

## What it does

|                             |                                                                                                                                                            |
| --------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Consent first**           | Klaro holds the tag back until the visitor agrees: no request to Google before                                                                             |
| **Content Security Policy** | Widened by Google's tag and collection addresses only                                                                                                      |
| **The tag**                 | Page views only; Google signals and ad personalisation off; never on administration or account pages; anonymous visitors only unless the site counts staff |
| **Dashboard**               | The **Analytics** tab of `/admin/dashboard`, and **Reports → Analytics**, for the App Admin                                                                |
| **Arabic**                  | The dashboard in Arabic, the Kingdom's cities by their Arabic names                                                                                        |
| **Charts**                  | Drawn on the server as SVG: no chart library, no CDN                                                                                                       |
| **Credentials**             | The service-account key written to the private files directory (0640), never the database; every change logged, never the key                              |

## Set it up

{% stepper %}
{% step %}

### Get the approval

Record the data protection officer's decision.
{% endstep %}

{% step %}

### Prepare Google

A GA4 property, its measurement ID and property ID, and a service account with read access to the property, with its JSON key.
{% endstep %}

{% step %}

### Apply the recipe

```bash
drush recipe modules/contrib/mutamad_analytics
```

{% endstep %}

{% step %}

### Enter the settings (administrator)

The measurement ID, the property ID and the JSON key, on GA4 Dashboard's settings page.
{% endstep %}

{% step %}

### Check

Open the site in a private window: nothing goes to Google until you accept the cookie notice. Run `mutamad-verify`.
{% endstep %}
{% endstepper %}
