Skip to content

Commit b9b4a05

Browse files
committed
Add more instructions into the docs itself
1 parent 9613f9c commit b9b4a05

15 files changed

+488
-30
lines changed

Gemfile.lock

+3
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,8 @@ GEM
211211
jekyll-seo-tag (~> 2.1)
212212
minitest (5.14.4)
213213
multipart-post (2.1.1)
214+
nokogiri (1.11.2-arm64-darwin)
215+
racc (~> 1.4)
214216
nokogiri (1.11.2-x86_64-darwin)
215217
racc (~> 1.4)
216218
octokit (4.20.0)
@@ -255,6 +257,7 @@ GEM
255257
zeitwerk (2.4.2)
256258

257259
PLATFORMS
260+
universal-darwin-21
258261
x86_64-darwin-19
259262
x86_64-darwin-20
260263

_docs/20_script/04_install.md

+10-9
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ permalink: /install-on-other-platforms
77

88
## Platform guides
99

10-
We try to make installing Simple Analytics as simple as possible. We want privacy to be accessible as possible. We don't require the need of a developer if you use any of the following tools.
10+
We try to make installing Simple Analytics as simple as possible. We want privacy to be accessible as possible. We don't require the need for a developer if you use any of the following tools.
1111

1212
Read our guides on how to install Simple Analytics on:
1313

@@ -25,19 +25,20 @@ Read our guides on how to install Simple Analytics on:
2525
2626
## Framework plugins
2727

28-
For most frameworks you can just include the script. We track page views in a magic way so you don't have to change your app code. [Read on how we do that](/trigger-custom-page-views). For some we got requests to create a plugin for them.
28+
For most frameworks, you can include the script. We magically track page views, so you don't have to change your app code. [Read on how we do that](/trigger-custom-page-views). For some, we got requests to create a plugin for them.
2929

3030
Get our official plugins for these frameworks:
3131

32-
- [Ruby on Rails](https://rubygems.org/gems/simple_analytics_rails) <small>(source on [GitHub](https://github.com/simpleanalytics/rubyonrails-plugin#readme))</small>
33-
- [Gatsby](https://www.npmjs.com/package/gatsby-plugin-simple-analytics) <small>(source on [GitHub](https://github.com/simpleanalytics/gatsby-plugin#readme))</small>
34-
- [Vue](https://www.npmjs.com/package/simple-analytics-vue) <small>(source on [GitHub](https://github.com/simpleanalytics/vue-plugin#readme))</small>
35-
- [VuePress](https://www.npmjs.com/package/vuepress-plugin-simple-analytics) <small>(source on [GitHub](https://github.com/simpleanalytics/vuepress-plugin#readme))</small>
32+
- [React](/install-simple-analytics-with-react) <small>(guide only)</small>
33+
- [Ruby on Rails](/install-simple-analytics-with-ruby-on-rails) <small>(source on [GitHub](https://github.com/simpleanalytics/rubyonrails-plugin#readme))</small>
34+
- [Gatsby](/install-simple-analytics-with-gatsby) <small>(source on [GitHub](https://github.com/simpleanalytics/gatsby-plugin#readme))</small>
35+
- [Vue](/install-simple-analytics-with-vue) <small>(source on [GitHub](https://github.com/simpleanalytics/vue-plugin#readme))</small>
36+
- [VuePress](/install-simple-analytics-with-vuepress) <small>(source on [GitHub](https://github.com/simpleanalytics/vuepress-plugin#readme))</small>
3637
- [Nuxt.js](/install-simple-analytics-with-nuxt) <small>(guide only)</small>
37-
- [Gridsome](https://gridsome.org/plugins/gridsome-plugin-simple-analytics) <small>(source on [GitHub](https://github.com/simpleanalytics/gridsome-plugin#readme))</small>
38-
- [Django](https://pypi.org/project/simpleanalytics/) <small>(source on [GitHub](https://github.com/simpleanalytics/django-plugin#readme))</small>
38+
- [Gridsome](/install-simple-analytics-with-gridsome) <small>(source on [GitHub](https://github.com/simpleanalytics/gridsome-plugin#readme))</small>
39+
- [Django](/install-simple-analytics-with-django) <small>(source on [GitHub](https://github.com/simpleanalytics/django-plugin#readme))</small>
3940
- [Analytics library](/install-simple-analytics-via-analytics-package) <small>(source on [GitHub](https://github.com/DavidWells/analytics/tree/master/packages/analytics-plugin-simple-analytics))</small>
4041
- [Hugo](/install-simple-analytics-with-hugo) <small>(guide only)</small>
41-
- [Next.js](https://github.com/simpleanalytics/next-js-app) <small>(sample app only)</small>
42+
- [Next.js](/install-simple-analytics-with-next) <small>(guide only)</small>
4243

4344
> Are you missing your favorite framework? [Let us know!](https://simpleanalytics.com/contact) Happy to create a plugin for you.

_docs/20_script/05_analytics.md

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,28 @@
11
---
22
title: Install Simple Analytics with the Analytics library
3-
menu: Install via `analytics`
43
category: script
54
hidden: true
65
permalink: /install-simple-analytics-via-analytics-package
76
---
87

9-
You can install Simple Analytics using the open source Analytics library ([website](https://getanalytics.io), [npm](https://www.npmjs.com/package/analytics)). It's a pluggable library designed as an abstraction layer to easily customize the analytics requirements of your app.
8+
You can install Simple Analytics using the open-source Analytics library ([website](https://getanalytics.io), [npm](https://www.npmjs.com/package/analytics)). It's a pluggable library designed as an abstraction layer to customize your app's analytics requirements easily.
109

1110
## Install via npm
1211

13-
```
12+
```bash
1413
npm install analytics analytics-plugin-simple-analytics
1514
```
1615

1716
## Using the Analytics library
1817

19-
The Analytics library works with any frontend framework including `react`, `vue`, `angular` or static `html`.
18+
The Analytics library works with any frontend framework, including `react`, `vue`, `angular` or static `html`.
2019

2120
To use it:
2221

2322
1. Import the `analytics` library and `analytics-plugin-simple-analytics`
2423
2. Initialize the `analytics` library
2524
3. Page views get tracked automatically
26-
4. Include the non javascript fallback in your `html`
25+
4. Include the non-javascript fallback in your `html`
2726

2827
Example code:
2928

@@ -45,17 +44,18 @@ const analytics = Analytics({
4544

4645
Make sure to include this file in the entry point of your application. This will ensure the Analytics library and Simple Analytics scripts load correctly.
4746

48-
When the Analytics library initialized it will automatically load the simple analytics script onto the page.
47+
When the Analytics library is initialized it will automatically load the simple analytics script onto the page.
4948

50-
For additional instructions on how to use with other frontend frameworks, checkout the [Analytics library docs](https://getanalytics.io/tutorial/getting-started/)
49+
For additional instructions on how to use with other frontend frameworks, check out the [Analytics library docs](https://getanalytics.io/tutorial/getting-started/)
5150

52-
## Include Non JS enabled browser fallback
51+
## Include non-JS enabled browser fallback
5352

54-
Remember to include the `noscript` image tag in your HTML for JS disabled browsers.
53+
Remember to include the `noscript` image tag in your HTML for JS-disabled browsers.
5554

5655
Include this line at the end of your `<body>`
5756

58-
```
57+
<!-- prettier-ignore -->
58+
```html
5959
<noscript><img src="https://queue.simpleanalyticscdn.com/noscript.gif" alt="" referrerpolicy="no-referrer-when-downgrade" /></noscript>
6060
```
6161

_docs/31_integrations/00_django.md

+86
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
---
2+
title: Install Simple Analytics with Django
3+
hidden: true
4+
category: integrations
5+
permalink: /install-simple-analytics-with-django
6+
---
7+
8+
Install the plugin:
9+
10+
```bash
11+
pip install simpleanalytics
12+
```
13+
14+
## Using it
15+
16+
Add the package to the `INSTALLED_APPS`:
17+
18+
```python
19+
INSTALLED_APPS = [
20+
...,
21+
simpleanalytics,
22+
]
23+
```
24+
25+
Next use the `templatetag` in your template:
26+
27+
```html
28+
<!DOCTYPE html>
29+
\{\% load static simpleanalytics_tags %}
30+
<html>
31+
<head>
32+
<meta charset="utf-8" />
33+
<title>\{\% block page_title %}\{{ site.name }}\{\% endblock %}</title>
34+
<meta
35+
name="viewport"
36+
content="width=device-width, initial-scale=1.0, user-scalable=no"
37+
/>
38+
... \{\% simpleanalytics_sync %} ...
39+
</head>
40+
<body>
41+
\{\% simpleanalytics_noscript_block %}
42+
</body>
43+
</html>
44+
```
45+
46+
This will translate to roughly this:
47+
48+
```
49+
<!DOCTYPE html>
50+
<html>
51+
<head>
52+
<meta charset="utf-8">
53+
<title>example.com</title>
54+
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no">
55+
...
56+
<script type="text/javascript" src="https://cdn.simpleanalytics.io/hello.js"></script>
57+
...
58+
</head>
59+
<body>
60+
<noscript><img src="https://api.simpleanalytics.io/hello.gif" alt="hello"></noscript>
61+
</body>
62+
</html>
63+
```
64+
65+
## Template tags
66+
67+
This app has four template tags:
68+
69+
- `simpleanalytics_sync`
70+
- `simpleanalytics_async`
71+
- `simpleanalytics_noscript_block`
72+
- `simpleanalytics_noscript_img`
73+
74+
`simpleanalytics_sync` converts to a plain `<script>` tag without the `async`
75+
keyword.
76+
77+
`simpleanalytics_async` converts to a plain `<script>` tag with the `async`
78+
keyword.
79+
80+
`simpleanalytics_noscript_block` converts to an `<noscript>` block, which
81+
includes an `img` element that is used to load the image. Use this when you
82+
don't have and don't need a `<noscript>` block on your page at all.
83+
84+
`simpleanalytics_noscript_img` converts to an `<img>` tag which src points to
85+
the hello.img. Use this when you're using a `<noscript>` block, and you want to
86+
add privacy-friendly stats to your page.

_docs/31_integrations/00_gatsby.md

+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
---
2+
title: Install Simple Analytics with Gatsby
3+
hidden: true
4+
category: integrations
5+
permalink: /install-simple-analytics-with-gatsby
6+
---
7+
8+
Run the following command:
9+
10+
```bash
11+
npm install gatsby-plugin-simple-analytics --save-dev
12+
```
13+
14+
## What does it do
15+
16+
It tracks page views with support for `pushState` navigation. It sends the data to [Simple Analytics](https://simpleanalytics.com) and it will be available in your dashboard. You need to have a paid subscription for it to work.
17+
18+
## How to use
19+
20+
1. Add our plugin to `gatsby-config.js`
21+
22+
```js
23+
plugins: [
24+
{
25+
resolve: "gatsby-plugin-simple-analytics",
26+
options: {
27+
trackPageViews: true,
28+
},
29+
},
30+
];
31+
```
32+
33+
1. If you want to set a custom domain, use this config:
34+
35+
```js
36+
plugins: [
37+
{
38+
resolve: "gatsby-plugin-simple-analytics",
39+
options: {
40+
domain: "custom.example.com",
41+
eventsGlobal: "sa",
42+
events: true,
43+
trackPageViews: true,
44+
ignorePages: ["pathname"],
45+
},
46+
},
47+
];
48+
```
49+
50+
[Read our docs](https://docs.simpleanalytics.com/bypass-ad-blockers) on the custom domain feature.
51+
52+
## Use with Confirmic
53+
54+
[Confirmic](https://confirmic.com/) provides a privacy-by-design API to ethically manage your users' data. It's pretty cool.
55+
56+
If you want to use it with Confirmic's `data-micropolicy` use this config:
57+
58+
```js
59+
plugins: [
60+
{
61+
resolve: "gatsby-plugin-simple-analytics",
62+
options: {
63+
metomic: "POLICY-SLUG",
64+
},
65+
},
66+
];
67+
```
68+
69+
It will result in something like this:
70+
71+
```html
72+
<script src="https://scripts.simpleanalyticscdn.com/latest.js" async="" defer="" type="text/x-metomic" data-micropolicy="POLICY-SLUG">
73+
```

_docs/31_integrations/00_gridsome.md

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: Install Simple Analytics with Gridsome
3+
hidden: true
4+
category: integrations
5+
permalink: /install-simple-analytics-with-gridsome
6+
---
7+
8+
Install our Gridsome package:
9+
10+
```bash
11+
npm install gridsome-plugin-simple-analytics
12+
```
13+
14+
### Usage
15+
16+
```js
17+
module.exports = {
18+
plugins: [
19+
{
20+
use: "gridsome-plugin-simple-analytics",
21+
},
22+
],
23+
};
24+
```
25+
26+
### Bypass Ad Blockers
27+
28+
You can also optionally specify a custom domain to bypass ad blockers. Read more about this in [our documentation](https://docs.simpleanalytics.com/bypass-ad-blockers).
29+
30+
```js
31+
module.exports = {
32+
plugins: [
33+
{
34+
use: "gridsome-plugin-simple-analytics",
35+
options: {
36+
domain: "api.example.com",
37+
},
38+
},
39+
],
40+
};
41+
```

_docs/31_integrations/00_hugo.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
title: Install Simple Analytics with Hugo
3-
menu: Hugo
43
hidden: true
54
category: integrations
65
permalink: /install-simple-analytics-with-hugo

_docs/31_integrations/00_jimdo.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
title: Install Simple Analytics on Jimdo Creator
3-
menu: Jimdo Creator
43
hidden: true
54
category: integrations
65
permalink: /install-simple-analytics-on-jimdo-creator

_docs/31_integrations/00_mailerlite.md

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
---
22
title: Install Simple Analytics on MailerLite
3-
menu: MailerLite
43
hidden: true
54
category: integrations
65
permalink: /install-simple-analytics-on-mailerlite

_docs/31_integrations/00_next.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
title: Install Simple Analytics with Next
3+
hidden: true
4+
category: integrations
5+
permalink: /install-simple-analytics-with-next
6+
---
7+
8+
Next has a lovely [Script component](https://nextjs.org/docs/basic-features/script).
9+
10+
In your app, you can add this Script component:
11+
12+
```js
13+
// _app.tsx
14+
import type { AppProps } from "next/app";
15+
import React from "react";
16+
import Script from "next/script";
17+
18+
function MyApp({ Component, pageProps }: AppProps) {
19+
return (
20+
<React.Fragment>
21+
<Component {...pageProps} />
22+
<Script src="https://scripts.simpleanalyticscdn.com/latest.js" />
23+
<noscript>
24+
{/* eslint-disable @next/next/no-img-element */}
25+
<img
26+
src="https://queue.simpleanalyticscdn.com/noscript.gif"
27+
alt=""
28+
referrerPolicy="no-referrer-when-downgrade"
29+
/>
30+
</noscript>
31+
</React.Fragment>
32+
);
33+
}
34+
35+
export default MyApp;
36+
```
37+
38+
It will use the `afterInteractive` strategy to load the script. From the docs:
39+
40+
> For scripts that can fetch and execute after the page is interactive, such as tag managers and analytics. These scripts are injected on the client-side and will run after hydration.

0 commit comments

Comments
 (0)