https://github.com/kmonsoor/lektor-google-analytics
Integration of Google analytics with Lektor CMS
https://github.com/kmonsoor/lektor-google-analytics
cms google-analytics lektor plugin static-site-generator
Last synced: 3 months ago
JSON representation
Integration of Google analytics with Lektor CMS
- Host: GitHub
- URL: https://github.com/kmonsoor/lektor-google-analytics
- Owner: kmonsoor
- License: other
- Created: 2016-01-01T19:14:25.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2021-08-23T14:19:26.000Z (almost 5 years ago)
- Last Synced: 2025-10-27T06:53:53.909Z (8 months ago)
- Topics: cms, google-analytics, lektor, plugin, static-site-generator
- Language: Python
- Size: 9.77 KB
- Stars: 9
- Watchers: 1
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# lektor-google-analytics
[]((https://opensource.org/licenses/BSD-3-Clause))
[](https://requires.io/github/kmonsoor/lektor-google-analytics/requirements/?branch=master)
This plugin adds support for [Google analytics](http://www.google.com/analytics/) to [Lektor CMS](https://github.com/lektor/lektor).
Once the plugin is enabled, a `generate_google_analytics()` function
is available to be included in target `template` which automatically include Google-Analytics code in final HTML files rendered by `Lektor`.
## Basic Usage
### Enabling the Plugin
To enable the plugin add this to your project file:
```ini
[packages]
lektor-google-analytics = 0.1.3
```
### Configuring the Plugin
The plugin needs a config file with your `Google analytics` code in it.
Just create a file named `google-analytics.ini` into `./configs` folder in your Lektor project's base directory. And, put the `GOOGLE_ANALYTICS_ID` key with target
property ID of form `UA-XXXXXXXX-Y` which you obtained from:
```ini
GOOGLE_ANALYTICS_ID = UA-XXXXXXXX-Y
```
### Using in Templates
Now you can add a Google analytics code-snippet in your templates by
just calling the `generate_google_analytics` function in its tag as below.
```html
{{ generate_google_analytics() }}
```
That's it. All the `HTML` files that rendered from that template will include Google-Analytics code automatically.
------
### Advanced
* You can use `GOOGLE_ANALYTICS_PROPERTY` property to include your custom-built
Google Analytics tracking code. In that case, your `./configs/google-analytics.ini` will look like this:
```ini
GOOGLE_ANALYTICS_ID = UA-XXXXXXXX-Y
GOOGLE_ANALYTICS_PROPERTY = 'my custom code'
```
Don't use this property unless you know what are you doing.
By default, it is set to `auto`.
To go deeper than this, please refer to
[Google-Analytics documentation](http://developers.google.com/analytics/devguides/collection/analyticsjs/).
------
**Copyright** (c) 2015, Khaled Monsoor
All rights reserved.
Licensed under [BSD](https://opensource.org/licenses/BSD-3-Clause) license.