Skip to content
This repository was archived by the owner on Mar 14, 2024. It is now read-only.

Commit cba5239

Browse files
Add example to README
1 parent 9c8d0f5 commit cba5239

File tree

1 file changed

+30
-1
lines changed

1 file changed

+30
-1
lines changed

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,33 @@
11
react-google-analytics
22
======================
33

4-
This inserts an up-to-date Google Analytics object whether Google updates their script or not
4+
Adds the Google Analytics script to your page and exposes the `ga` tracking
5+
function as a module.
6+
7+
Usage:
8+
9+
```javascript
10+
var ga = require('react-google-analytics');
11+
var GAInitiailizer = ga.Initializer;
12+
13+
// Use the initializer to add the script to your page somewhere.
14+
var MyComponent = React.createClass({
15+
render: function() {
16+
return (
17+
<div>
18+
// SNIP
19+
<GAInitiailizer />
20+
// SNIP
21+
</div>
22+
);
23+
}
24+
});
25+
```
26+
27+
Elsewhere, use the `ga` function:
28+
29+
```javascript
30+
var ga = require('react-google-analytics');
31+
ga('create', 'UA-XXXX-Y', 'auto');
32+
ga('send', 'pageview');
33+
```

0 commit comments

Comments
 (0)