Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Support Seline Analysis #1640

Merged
merged 3 commits into from
Aug 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ disableTextInHeader = false
# websiteid = "ABC12345"
# domain = "llama.yoursite.com"
# dataDomains = "yoursite.com,yoursite2.com"
# enableTrackEvent = true

[selineAnalytics]
# token = "XXXXXX"
# enableTrackEvent = true

[buymeacoffee]
# identifier = ""
Expand Down
5 changes: 5 additions & 0 deletions exampleSite/config/_default/params.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,11 @@ smartTOCHideUnfocusedChildren = false
# websiteid = "ABC12345"
# domain = "llama.yoursite.com"
# dataDomains = "yoursite.com,yoursite2.com"
# enableTrackEvent = false

[selineAnalytics]
# token = "XXXXXX"
# enableTrackEvent = false

[buymeacoffee]
identifier = "nunocoracao"
Expand Down
8 changes: 8 additions & 0 deletions exampleSite/content/docs/configuration/index.it.md
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,14 @@ Many of the article defaults here can be overridden on a per article basis by sp
| `umamiAnalytics.websiteid` | _Not set_ | The site code generated by Umami Analytics for the website. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details. |
| `umamiAnalytics.domain` | _Not set_ | If using a custom domain with Umami Analytics, provide it here to serve `script.js` from the custom domain. |
| `umamiAnalytics.dataDomains` | _Not set_ | If you want the tracker to only run on specific domains, provide it for your tracker script. This is a comma delimited list of domain names. Such as "yoursite.com,yoursite2.com". |
| `umamiAnalytics.enableTrackEvent` | true | When set to `true` track event will add automatically. If you do not want to add track event, set it to `false`. |

### Seline Analytics

| Name | Default | Description |
|-----------------------------------|-----------|-------------------------------------------------------------------------------------------------------------------------------------------|
| `selineAnalytics.token` | _Not set_ | The token generated by Seline Analytics for the website. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details. |
| `selineAnalytics.enableTrackEvent` | true | When set to `true` track event will add automatically. If you do not want to add track event, set it to `false`. |

### BuyMeACoffee

Expand Down
8 changes: 8 additions & 0 deletions exampleSite/content/docs/configuration/index.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,14 @@ Many of the article defaults here can be overridden on a per article basis by sp
| `umamiAnalytics.websiteid` | _Not set_ | The site code generated by Umami Analytics for the website. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details. |
| `umamiAnalytics.domain` | _Not set_ | If using a custom domain with Umami Analytics, provide it here to serve `script.js` from the custom domain. |
| `umamiAnalytics.dataDomains` | _Not set_ | If you want the tracker to only run on specific domains, provide it for your tracker script. This is a comma delimited list of domain names. Such as "yoursite.com,yoursite2.com". |
| `umamiAnalytics.enableTrackEvent` | true | When set to `true` track event will add automatically. If you do not want to add track event, set it to `false`. |

### Seline Analytics

| Name | Default | Description |
|-----------------------------------|-----------|-------------------------------------------------------------------------------------------------------------------------------------------|
| `selineAnalytics.token` | _Not set_ | The token generated by Seline Analytics for the website. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details. |
| `selineAnalytics.enableTrackEvent` | true | When set to `true` track event will add automatically. If you do not want to add track event, set it to `false`. |

### BuyMeACoffee

Expand Down
15 changes: 11 additions & 4 deletions exampleSite/content/docs/configuration/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,19 @@ Many of the article defaults here can be overridden on a per article basis by sp

### Umami Analytics

| Name | Default | Description |
| -------------------------- | --------- |-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `umamiAnalytics.websiteid` | _Not set_ | The site code generated by Umami Analytics for the website. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details. |
| `umamiAnalytics.domain` | _Not set_ | If using a custom domain with Umami Analytics, provide it here to serve `script.js` from the custom domain. |
| Name | Default | Description |
| -------------------------- |-----------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `umamiAnalytics.websiteid` | _Not set_ | The site code generated by Umami Analytics for the website. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details. |
| `umamiAnalytics.domain` | _Not set_ | If using a custom domain with Umami Analytics, provide it here to serve `script.js` from the custom domain. |
| `umamiAnalytics.dataDomains` | _Not set_ | If you want the tracker to only run on specific domains, provide it for your tracker script. This is a comma delimited list of domain names. Such as "yoursite.com,yoursite2.com". |
| `umamiAnalytics.enableTrackEvent` | true | When set to `true` track event will add automatically. If you do not want to add track event, set it to `false`. |

### Seline Analytics

| Name | Default | Description |
|-----------------------------------|-----------|-------------------------------------------------------------------------------------------------------------------------------------------|
| `selineAnalytics.token` | _Not set_ | The token generated by Seline Analytics for the website. Refer to the [Analytics docs]({{< ref "partials#analytics" >}}) for more details. |
| `selineAnalytics.enableTrackEvent` | true | When set to `true` track event will add automatically. If you do not want to add track event, set it to `false`. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should definitely default to false or not set to match all the other analytics engines. Otherwise, you're enabling it for every user by default.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These should definitely default to false or not set to match all the other analytics engines. Otherwise, you're enabling it for every user by default.

In my opinion enableTrackEvent=true is recommended for optimal data tracking and display.

If you want to customize event tracking, might set it to false, and then add manually invoking umami.track() or seline.track() for specific events.
However, for most users this customization is unnecessary.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see, there's an outer guard here in analytics/main.html.


### BuyMeACoffee

Expand Down
18 changes: 13 additions & 5 deletions exampleSite/content/docs/configuration/index.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -321,11 +321,19 @@ Blowfish 提供了大量控制主题功能的配置参数,下面的表格中

### Umami Analytics

| Name | Default | Description |
| -------------------------- | --------- |-------------------------------------------------------------------------------------|
| `umamiAnalytics.websiteid` | _Not set_ | 支持 Umami 站点分析平台。更多详细内容请参考 [分析文档]({{< ref "partials#analytics" >}})。 |
| `umamiAnalytics.domain` | _Not set_ | 如果使用自定义域名的 Umami Analytics,请在此提供,以便从自定义域名获取 `script.js`。 |
| `umamiAnalytics.dataDomains` | _Not set_ | 如果你只想在特别的数个域名中使用 tracker 功能,那么你需要设置它。这个参数的值是逗号分隔的域名列表,如:yoursite.com,yoursite2.com。 |
| Name | Default | Description |
|------------------------------|-----------|-------------------------------------------------------------------------------------|
| `umamiAnalytics.websiteid` | 无 | 支持 Umami 站点分析平台。更多详细内容请参考 [分析文档]({{< ref "partials#analytics" >}})。 |
| `umamiAnalytics.domain` | 无 | 如果使用自定义域名的 Umami Analytics,请在此提供,以便从自定义域名获取 `script.js`。 |
| `umamiAnalytics.dataDomains` | 无 | 如果你只想在特别的数个域名中使用 tracker 功能,那么你需要设置它。这个参数的值是逗号分隔的域名列表,如:yoursite.com,yoursite2.com。 |
| `umamiAnalytics.enableTrackEvent` | true | 默认会自动添加 Umami Track Event。如果你不想添加 Event,那学需要设置为 `false`。 |

### Seline Analytics

| Name | Default | Description |
|-----------------------------------|---------|--------------------------------------------------------------------------|
| `selineAnalytics.token` | 无 | Seline 站点分析平台的 token。更多详细内容请参考 [分析文档]({{< ref "partials#analytics" >}})。 |
| `selineAnalytics.enableTrackEvent` | true | 默认会自动添加 Umami Track Event。如果你不想添加 Event,那学需要设置为 `false`。 |


### BuyMeACoffee
Expand Down
20 changes: 20 additions & 0 deletions exampleSite/content/docs/partials/index.it.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,35 @@ To enable Umami Analytics support, simply provide your [Umami tracking code](htt
If you also use the custom domain feature of Umami and would like to serve their script from your domain, you can also additionally provide the `domain` configuration value. If you don't provide a `domain` value, the script will load directly from Umami DNS (analytics.umami.is).
If you want the tracker to only run on specific domains, you can provide the `dataDomains` configuration value. If you don't provide a `dataDomains` value, the script will run on any website where the `domain` and` websiteid` match.

{{< alert >}}
**Note:** If you enable Umami Analytics, Blowfish will support [Umami Track Event](https://umami.is/docs/track-events) automatically. If you do not want to support Track Event, the param `enableTrackEvent` must set to `false`.
{{< /alert >}}

```toml
# config/_default/params.toml

[umamiAnalytics]
websiteid = "ABC12345"
domain = "llama.yoursite.com"
dataDomains = "yoursite.com,yoursite2.com"
enableTrackEvent = true
```

### Seline Analytics

To enable Seline Analytics support, simply provide your [Seline token](https://seline.so/docs/install-seline) in the `config/_default/params.toml` file.

{{< alert >}}
**Note:** If you enable Seline Analytics, Blowfish will support [Seline Track Event](https://seline.so/docs/custom-events) automatically. If you do not want to support Track Event, the param `enableTrackEvent` must set to `false`.
{{< /alert >}}

```toml
# config/_default/params.toml

[selineAnalytics]
token = "XXXXXX"
enableTrackEvent = true
```
### Custom analytics providers

If you wish to use a different analytics provider on your website you can also override the analytics partial and provide your own script. Simply create the file `layouts/partials/extend-head.html` in your project and it will automatically include it in the `<head>` of the website.
Expand Down
20 changes: 20 additions & 0 deletions exampleSite/content/docs/partials/index.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,33 @@ To enable Umami Analytics support, simply provide your [Umami tracking code](htt
If you also use the custom domain feature of Umami and would like to serve their script from your domain, you can also additionally provide the `domain` configuration value. If you don't provide a `domain` value, the script will load directly from Umami DNS (analytics.umami.is).
If you want the tracker to only run on specific domains, you can provide the `dataDomains` configuration value. If you don't provide a `dataDomains` value, the script will run on any website where the `domain` and` websiteid` match.

{{< alert >}}
**Note:** If you enable Umami Analytics, Blowfish will support [Umami Track Event](https://umami.is/docs/track-events) automatically. If you do not want to support Track Event, the param `enableTrackEvent` must set to `false`.
{{< /alert >}}

```toml
# config/_default/params.toml

[umamiAnalytics]
websiteid = "ABC12345"
domain = "llama.yoursite.com"
dataDomains = "yoursite.com,yoursite2.com"
enableTrackEvent = true
```

### Seline Analytics

To enable Seline Analytics support, simply provide your [Seline token](https://seline.so/docs/install-seline) in the `config/_default/params.toml` file.
{{< alert >}}
**Note:** If you enable Seline Analytics, Blowfish will support [Seline Track Event](https://seline.so/docs/custom-events) automatically. If you do not want to support Track Event, the param `enableTrackEvent` must set to `false`.
{{< /alert >}}

```toml
# config/_default/params.toml

[selineAnalytics]
token = "XXXXXX"
enableTrackEvent = true
```

### Custom analytics providers
Expand Down
22 changes: 22 additions & 0 deletions exampleSite/content/docs/partials/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,35 @@ googleAnalytics = "G-MEASUREMENT_ID"
To enable Umami Analytics support, simply provide your [Umami tracking code](https://umami.is/docs/collect-data) in the `config/_default/params.toml` file.
If you also use the custom domain feature of Umami and would like to serve their script from your domain, you can also additionally provide the `domain` configuration value. If you don't provide a `domain` value, the script will load directly from Umami DNS (analytics.umami.is).
If you want the tracker to only run on specific domains, you can provide the `dataDomains` configuration value. If you don't provide a `dataDomains` value, the script will run on any website where the `domain` and` websiteid` match.

{{< alert >}}
**Note:** If you enable Umami Analytics, Blowfish will support [Umami Track Event](https://umami.is/docs/track-events) automatically. If you do not want to support Track Event, the param `enableTrackEvent` must set to `false`.
{{< /alert >}}

```toml
# config/_default/params.toml

[umamiAnalytics]
websiteid = "ABC12345"
domain = "llama.yoursite.com"
dataDomains = "yoursite.com,yoursite2.com"
enableTrackEvent = true
```

### Seline Analytics

To enable Seline Analytics support, simply provide your [Seline token](https://seline.so/docs/install-seline) in the `config/_default/params.toml` file.

{{< alert >}}
**Note:** If you enable Seline Analytics, Blowfish will support [Seline Track Event](https://seline.so/docs/custom-events) automatically. If you do not want to support Track Event, the param `enableTrackEvent` must set to `false`.
{{< /alert >}}

```toml
# config/_default/params.toml

[selineAnalytics]
token = "XXXXXX"
enableTrackEvent = true
```

### Custom analytics providers
Expand Down
22 changes: 22 additions & 0 deletions exampleSite/content/docs/partials/index.zh-cn.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,11 @@ googleAnalytics = "G-MEASUREMENT_ID"
如果你想使用自定义域名来获取跟踪脚本, 那么需要提供 `domain` 参数,否则会从 Umami 云服务版的地址 (analytics.umami.is) 获取脚本。
如果你只想在特别的数个域名中使用 tracker 功能,那么需要提供 `dataDomains` 参数。否则任何一个匹配了 `websiteid` 和 `domain` 参数值的网站,Umami 脚本都会执行。

{{< alert >}}
**Note:** 开启 Umami 网站分析后, Blowfish 会自动支持 [Umami 事件追踪](https://umami.is/docs/track-events)。如果你不想支持此功能,需要把参数 `enableTrackEvent` 设置为 `false`。

{{< /alert >}}

```toml
# config/_default/params.toml

Expand All @@ -59,6 +64,23 @@ googleAnalytics = "G-MEASUREMENT_ID"
dataDomains = "yoursite.com,yoursite2.com"
```

### Seline

只需要在 `config/_default/params.toml` 文件提供你的 [Seline token](https://seline.so/docs/install-seline),就可以快速支持 Seline 站点分析。

{{< alert >}}
**Note:** 开启 Seline 网站分析后, Blowfish 会自动支持 [Seline 事件追踪](https://seline.so/docs/custom-events)。如果你不想支持此功能,需要把参数 `enableTrackEvent` 设置为 `false`。
{{< /alert >}}

```toml
# config/_default/params.toml

[selineAnalytics]
token = "XXXXXX"
enableTrackEvent = true
```


### 提供自定义站点分析

如果你想在你的网站提供其他站点分析,你可以自己提供脚本,并覆盖 Blowfish 主题中内置的 partial。
Expand Down
3 changes: 3 additions & 0 deletions layouts/partials/analytics/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@
{{ end }}
{{ with site.Params.umamiAnalytics.websiteid }}
{{ partial "analytics/umami.html" }}
{{ end }}
{{ with site.Params.selineAnalytics.token }}
{{ partial "analytics/seline.html" }}
{{ end }}
18 changes: 18 additions & 0 deletions layouts/partials/analytics/seline.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<script async src="https://cdn.seline.so/seline.js" data-token="{{ site.Params.selineAnalytics.token }}" data-id="seline-script"></script>

{{ if .Site.Params.selineAnalytics.enableTrackEvent | default true }}
<script type="text/javascript">
document.querySelector('script[data-id="seline-script"]')
.addEventListener('load', function () {
const type = document.head.querySelector('meta[property = "og:type"]').getAttribute('content');
let title = document.head.querySelector('meta[property = "og:title"]').getAttribute('content');
let url = document.head.querySelector('meta[property = "og:url"]').getAttribute('content');

seline.track("user:" + type + ':' + title, {
type: type,
title: title,
url: url
});
});
</script>
{{ end }}
4 changes: 3 additions & 1 deletion layouts/partials/analytics/umami.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
</script>
{{ end }}

{{ if .Site.Params.umamiAnalytics.enableTrackEvent | default true }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same comment here -- I don't think these should be defaulting to enabled.

<script type="text/javascript">
document.querySelector('script[data-id="umami-script"]')
.addEventListener('load', function () {
Expand All @@ -18,4 +19,5 @@
let url = document.head.querySelector('meta[property = "og:url"]').getAttribute('content');
umami.track(type + ':' + title, {'url': url});
});
</script>
</script>
{{ end }}