You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: SvelteFire PageView Component API reference
5
+
layout: ../../layouts/MainLayout.astro
6
+
---
7
+
8
+
# PageView
9
+
10
+
The `PageView` component logs a Google analytics `page_view` event when it is mounted.
11
+
12
+
### Slot Props
13
+
14
+
-`eventName` - (default: 'page_view') Set the current user as the userId in Google Analytics
15
+
-`setUser` - (default: true) Set the current user as the userId in Google Analytics
16
+
-`customParams` - (optional) custom parameters to pass to the `signIn` function
17
+
18
+
### Layout Example (recommended)
19
+
20
+
The most efficient way to integrate Firebase Analytics is to log events from a layout component. This will ensure that every route change is logged, both on the client and server. Make sure to `key` the `PageView` component so that it is re-mounted on every route change.
21
+
22
+
```svelte
23
+
<!-- +layout.svelte -->
24
+
<script lang="ts">
25
+
import { page } from "$app/stores";
26
+
import { PageView } from "sveltefire";
27
+
</script>
28
+
29
+
<slot />
30
+
31
+
{#key $page.route.id}
32
+
<PageView />
33
+
{/key}
34
+
```
35
+
36
+
### Page Example
37
+
38
+
For fine-grained control, you can include `PageView` on a page-by-page basis. This is useful when sending custom parameters.
0 commit comments