https://github.com/simpleanalytics/rubyonrails-plugin
https://github.com/simpleanalytics/rubyonrails-plugin
Last synced: 8 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/simpleanalytics/rubyonrails-plugin
- Owner: simpleanalytics
- License: mit
- Created: 2021-03-29T10:14:07.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-11-05T12:25:12.000Z (over 4 years ago)
- Last Synced: 2025-07-04T02:48:38.205Z (12 months ago)
- Language: Ruby
- Size: 89.8 KB
- Stars: 6
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
Simple Analytics Rails
[Simple Analytics](https://simpleanalytics.com/) is a privacy friendly analytics. No consent required from your visitors!
This gem adds the [JavaScript Tracking Script](https://docs.simpleanalytics.com/script) to the `` & `` tag of your Ruby on Rails applications.
## 🚀 Installation
Add this line to your application's Gemfile:
```ruby
gem 'simple_analytics_rails'
```
And then execute:
```bash
$ bundle install
```
Or install it yourself as:
```bash
$ gem install simple_analytics_rails
````
## ✨ Usage
After the gem is installed, it will automatically append the Simple Analytics JavaScript snippet before the `` tag on your HTML pages.
However you can also configure it via an initializer:
```ruby
# config/initializers/simple_analytics.rb
SimpleAnalyticsRails.configure do |configuration|
# ==> Overwrite domain name
# https://docs.simpleanalytics.com/overwrite-domain-name
#
# Default is ""
configuration.hostname = "example.com"
# ==> Hash mode
# https://docs.simpleanalytics.com/hash-mode
#
# Default is ""
configuration.mode = "hash"
# ==> Do not track
# https://docs.simpleanalytics.com/dnt
#
# Default is false
configuration.collect_dnt = false
# ==> Ignore pages
# https://docs.simpleanalytics.com/ignore-pages
#
# Default is ""
configuration.ignore_pages = "/search/*,/account/*,/vouchers"
# ==> Override variable used for JavaScript Events
# https://docs.simpleanalytics.com/events#the-variable-sa_event-is-already-used
#
# Default is "sa_event"
configuration.sa_global = "sa_event"
# ==> Trigger custom page views
# https://docs.simpleanalytics.com/trigger-custom-page-views#use-custom-collection-anyway
#
# Default is true
configuration.auto_collect = true
# ==> Onload Callback
# https://docs.simpleanalytics.com/trigger-custom-page-views#use-custom-collection-anyway
#
# Default is ""
configuration.onload_callback = "onloadCallback()"
# ==> Custom Domain
# https://docs.simpleanalytics.com/bypass-ad-blockers
#
# Default is ""
configuration.custom_domain = "custom.domain.com"
# ==> Inject JavaScript To Head
# You can disable the automatic JavaScript injection if you'd like.
#
# Default is true
configuration.enabled = Rails.env.production?
end
```
## 🙏 Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/simpleanalytics/rubyonrails-plugin .
### Code of Conduct
Everyone interacting in the SimpleAnalyticsRails project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/simpleanalytics/rubyonrails-plugin/blob/main/CODE_OF_CONDUCT.md).
### Coding Standards
This project uses [Standard](https://github.com/testdouble/standard) for Ruby code to minimize bike shedding related to source formatting.
Please run `bundle exec standardrb --fix` prior to submitting pull requests.
## 📦 Releasing
1. Bump version number at `lib/simple_analytics_rails/version.rb`
1. Commit and push changes
1. Publish a new release on GitHub https://github.com/simpleanalytics/rubyonrails-plugin/releases/new
1. A [GitHub Action](https://github.com/simpleanalytics/rubyonrails-plugin/blob/main/.github/workflows/publish.yml) will then publish the latest version to https://rubygems.org/
## 📝 License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).