File tree Expand file tree Collapse file tree 1 file changed +49
-6
lines changed
Expand file tree Collapse file tree 1 file changed +49
-6
lines changed Original file line number Diff line number Diff line change @@ -3,15 +3,58 @@ title: Install Simple Analytics with React
33hidden : true
44category : integrations
55permalink : /install-simple-analytics-with-react
6- last_modified_at : 2022-04-14
6+ last_modified_at : 2025-10-22
77---
88
9- Most projects have the structure of ` npx create-react-app my-app ` . Let's follow that structure .
9+ Add Simple Analytics to React apps with our official React package .
1010
11- You don't need any dependency to install Simple Analytics.
11+ ## Install
1212
13- 1 . Go to your HTML file: usually in ` public/index.html `
14- 2 . Paste the embed code from [ how to add our script] ( /script ) at the end of body of that file.
15- 3 . Save this file and you're done!
13+ Run this command to install Simple Analytics for React:
14+
15+ ``` bash
16+ npm i @simpleanalytics/react
17+ ```
18+
19+ ## Usage
20+
21+ Import the ` <SimpleAnalytics /> ` to start tracking pageviews
22+
23+ ``` tsx
24+ import { SimpleAnalytics } from " @simpleanalytics/react" ;
25+
26+ export function App() {
27+ return (
28+ <>
29+ { /* your app */ }
30+ <SimpleAnalytics />
31+ </>
32+ );
33+ }
34+ ```
35+
36+ ## Options
37+
38+ - ** Custom domain** : see [ /bypass-ad-blockers] ( /bypass-ad-blockers )
39+
40+ ``` tsx
41+ <SimpleAnalytics domain = " custom.domain.com" />
42+ ```
43+
44+ ## Send events
45+
46+ ``` tsx
47+ import { trackEvent } from " @simpleanalytics/react" ;
48+
49+ function Button() {
50+ return (
51+ <button onClick = { () => trackEvent (" clicked" )} >
52+ Track event
53+ </button >
54+ );
55+ }
56+ ```
57+
58+ Note: ` trackEvent ` requires ` <SimpleAnalytics /> ` to be present in your app.
1659
1760If you encounter issues, don't hesitate to contact us via [ our support channels] ( https://simpleanalytics.com/contact ) .
You can’t perform that action at this time.
0 commit comments