import { Meta } from '@storybook/blocks';
import * as AnalyticsStories from './Analytics.stories.svelte';
# Analytics
The `Analytics` component adds Google and Chartbeat analytics to your page.
```svelte
```
## Environments
Generally, you only want to send page analytics in production environments.
In a SvelteKit context, you can use `$app` stores to restrict when you send analytics.
For example, the following excludes analytics from pages in development or hosted on our preview server:
```svelte
{#if !dev && $page.url?.hostname !== 'graphics.thomsonreuters.com'}
{/if}
```
## Multipage apps
If you're using analytics to measure a multipage newsapp that uses [client-side routing](https://kit.svelte.dev/docs/glossary#routing), then you may need to trigger analytics after virtual page navigation.
This component exports a function you can call to register pageviews.
For example, here's how you can use SvelteKit's [`afterNavigate`](https://kit.svelte.dev/docs/modules#$app-navigation-afternavigate) lifecycle to capture additional pageviews:
```svelte
```