isc_analytics 0.5.1 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.md
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
# ISC Analytics
|
2
|
-
A simple client-side & server-side analytics library for Rails
|
1
|
+
# ISC Analytics [](https://travis-ci.org/TheGiftsProject/isc_analytics)
|
2
|
+
A simple client-side & server-side analytics library for Rails. It currently supports only KISSmetrics for more advanced
|
3
|
+
analytics features (trackEvent / setProperties) and Google Analytics just for tracking pageviews.
|
3
4
|
|
4
5
|
## Installation
|
5
6
|
|
@@ -9,21 +10,21 @@ Just add the `isc_analytics` gem into your Gemfile
|
|
9
10
|
gem 'isc_analytics'
|
10
11
|
```
|
11
12
|
|
12
|
-
Then
|
13
|
+
Then add an initializer file in your `config/initializers` directory containing the initial config of your analytics.
|
13
14
|
|
14
15
|
## Configuration
|
15
16
|
|
16
|
-
ISC Analytics
|
17
|
+
ISC Analytics currently supports the following configuration options:
|
17
18
|
|
18
19
|
|
19
20
|
```ruby
|
20
|
-
IscAnalytics.config.accounts = ANALYTIC_ACCOUNTS # an accounts
|
21
|
+
IscAnalytics.config.accounts = ANALYTIC_ACCOUNTS # an accounts object (preferably using ConfigReader)
|
21
22
|
IscAnalytics.config.namespace = 'App' # an alias which will gain all the analytics behivour in the clientside.
|
22
23
|
```
|
23
24
|
|
24
|
-
We recommend our other gem [ConfigReader](https://github.com/TheGiftsProject/configreader) to load the analytics_accounts data from a YML.
|
25
|
+
We highly recommend you to use our other gem [ConfigReader](https://github.com/TheGiftsProject/configreader) to load the analytics_accounts data from a YML.
|
25
26
|
|
26
|
-
The
|
27
|
+
The accounts hash / EnvConfigReader should contain the following sub keys:
|
27
28
|
|
28
29
|
```yml
|
29
30
|
kissmetrics_key: "KEY"
|
@@ -36,29 +37,37 @@ Currently only the KISSMetrics and Google Analytics keys are mandatory although
|
|
36
37
|
|
37
38
|
## Usage
|
38
39
|
|
39
|
-
|
40
|
+
The basic way to use isc_analytics is to simply follow the **Getting Started** step, which will guide you on how
|
41
|
+
to enable simple visitor tracking in KISSmetrics and Google Analytics
|
40
42
|
|
41
|
-
|
43
|
+
If you need more, there's a client-side & server-side tracking analytics API. (Enabled just for KISSmetrics)
|
44
|
+
|
45
|
+
## Getting Started
|
46
|
+
|
47
|
+
After you've finished configuring isc_analytics, do the following in order to include it in your app:
|
48
|
+
|
49
|
+
#### ApplicationController
|
42
50
|
|
43
|
-
To include isc_analytics in your app, after you install the gem.
|
44
51
|
Add the following line inside your ApplicationController:
|
45
52
|
|
46
53
|
```ruby
|
47
54
|
include IscAnalytics::ControllerSupport
|
48
55
|
```
|
49
|
-
This will enable you to use the
|
56
|
+
This will enable you to use the Analytics object from your controllers and views.
|
50
57
|
|
51
|
-
|
58
|
+
#### Application Layout
|
59
|
+
|
60
|
+
Add the following line to your main application layout, under the HTML head tag.
|
52
61
|
|
53
62
|
```erb
|
54
63
|
<%= add_analytics %>
|
55
64
|
```
|
56
65
|
|
57
|
-
This will embed all the needed
|
66
|
+
This will embed all the needed HTML for the analytics to run (including the code for all the required services).
|
58
67
|
|
59
|
-
|
68
|
+
## Client Side
|
60
69
|
|
61
|
-
|
70
|
+
Once you've included isc_analytics as we've explained above, you will have access to the following client-side API:
|
62
71
|
|
63
72
|
```js
|
64
73
|
Analytics.trackEvent(<event name>, [<properties_hash>]);
|
@@ -68,14 +77,15 @@ Analytics.identify(<identity>, [<properties_hash>]);
|
|
68
77
|
Analytics.clearIdentity()
|
69
78
|
```
|
70
79
|
|
71
|
-
|
72
|
-
|
80
|
+
### Namespacing
|
81
|
+
|
82
|
+
If you've configured a Namespace in the initializer, then we'll automatically alias all the functions to the Namespace of your choice for easy access.
|
73
83
|
For example if I set my namespace as `App` then I'll be able to access the trackEvent function from `App.trackEvent`
|
74
84
|
|
75
|
-
|
85
|
+
## Server Side
|
76
86
|
|
77
|
-
All the **client side event tracking is available from the server side** as well. Once you
|
78
|
-
For example you can call `analytics.trackEvent('user-visit')` and it will be persisted in the current user session and flushed into the
|
87
|
+
All the **client side event tracking is available from the server side** as well. Once you've included isc_analytics you can access the `analytics` object which will have methods identical to the client-side analytics methods.
|
88
|
+
For example you can call `analytics.trackEvent('user-visit')` and it will be persisted in the current user session and flushed into the user's browser next time he visits a page (via add_analytics). This mechanism is similar in behaviour to Rails' flash object.
|
79
89
|
|
80
90
|
### Opt out
|
81
91
|
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require isc_analytics/index
|
data/lib/isc_analytics/engine.rb
CHANGED
@@ -1,12 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
IscAnalytics.app = app
|
7
|
-
app.config.assets.precompile += %w(isc_analytics isc_analytics/session isc_analytics/opt_out_analytics)
|
8
|
-
end
|
9
|
-
end
|
1
|
+
module IscAnalytics
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
initializer 'isc_analytics.assets' do |app|
|
4
|
+
IscAnalytics.app = app
|
5
|
+
app.config.assets.precompile += %w(isc_analytics.js isc_analytics/session.js isc_analytics/opt_out_analytics.js)
|
10
6
|
end
|
11
7
|
end
|
12
|
-
end
|
8
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require isc_analytics/session/index
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: isc_analytics
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2012-12-
|
13
|
+
date: 2012-12-30 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: controller_support
|
@@ -72,6 +72,7 @@ files:
|
|
72
72
|
- lib/assets/javascripts/isc_analytics/isc_analytics.js.coffee
|
73
73
|
- lib/assets/javascripts/isc_analytics/opt_out_analytics.js.coffee
|
74
74
|
- lib/assets/javascripts/isc_analytics/visitor_analytics.coffee.erb
|
75
|
+
- lib/assets/javascripts/isc_analytics.js
|
75
76
|
- lib/isc_analytics/bootstrap.rb
|
76
77
|
- lib/isc_analytics/client_api.rb
|
77
78
|
- lib/isc_analytics/config.rb
|
@@ -83,6 +84,7 @@ files:
|
|
83
84
|
- lib/isc_analytics.rb
|
84
85
|
- vendor/assets/javascripts/isc_analytics/session/index.js
|
85
86
|
- vendor/assets/javascripts/isc_analytics/session/session-0.4.js
|
87
|
+
- vendor/assets/javascripts/isc_analytics/session.js
|
86
88
|
- vendor/assets/javascripts/isc_analytics/yepnope/css_prefix.js
|
87
89
|
- vendor/assets/javascripts/isc_analytics/yepnope/index.js
|
88
90
|
- vendor/assets/javascripts/isc_analytics/yepnope/yepnope.js
|