ga_dashboard 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --format documentation
2
+ --color
@@ -0,0 +1,4 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ before_install: gem install bundler -v 1.10.6
@@ -0,0 +1,13 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, we pledge to respect all people who contribute through reporting issues, posting feature requests, updating documentation, submitting pull requests or patches, and other activities.
4
+
5
+ We are committed to making participation in this project a harassment-free experience for everyone, regardless of level of experience, gender, gender identity and expression, sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
6
+
7
+ Examples of unacceptable behavior by participants include the use of sexual language or imagery, derogatory comments or personal attacks, trolling, public or private harassment, insults, or other unprofessional conduct.
8
+
9
+ Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed from the project team.
10
+
11
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by opening an issue or contacting one or more of the project maintainers.
12
+
13
+ This Code of Conduct is adapted from the [Contributor Covenant](http://contributor-covenant.org), version 1.0.0, available at [http://contributor-covenant.org/version/1/0/0/](http://contributor-covenant.org/version/1/0/0/)
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in ga_dashboard.gemspec
4
+ gemspec
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2015 Saraswathy Renuga
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,176 @@
1
+ # GA Dashboard
2
+
3
+ This gem helps you to import Google Analytics Dashboard into your Rails application.
4
+
5
+ You can pull out the following stats from Google Analytics
6
+
7
+ 1. Most Popular Pages
8
+ 2. Geo Chart (Map) or Table which represents the following data for a given time period
9
+ * Users count from various countries across the world
10
+ * Users count from various countries in a continent
11
+ * Users count from various cities of a country
12
+ 3. Overview of users and sessions for a given time period as line chart
13
+
14
+ ## Installation
15
+
16
+ Add this line to your application's Gemfile:
17
+
18
+ ```ruby
19
+ gem 'ga_dashboard'
20
+ ```
21
+
22
+ And then execute:
23
+
24
+ $ bundle
25
+
26
+ Or install it yourself as:
27
+
28
+ $ gem install ga_dashboard
29
+
30
+ ## Usage
31
+
32
+ ###Prerequisites
33
+
34
+ You need to set up the following things before using this gem.
35
+
36
+ 1. Create Google Analytics account for your project, add the script with tracking code in all the view pages that you want to track.
37
+ 2. Create a project at [Google Developers Console](https://code.google.com/apis/console/)
38
+ 3. In Google Developers console, Select your Project -> API & auth -> Search for Analytics -> Enable API
39
+ 4. Under API & auth -> Credentials -> Add Credentials -> Service Account -> Select P12 and create
40
+ 5. Download the **Key file** and save it in your_project_folder/lib/keys
41
+ 6. Note down the **service email address** that is created. It should be something like ‘something-long@developer.gserviceaccount.com’
42
+ 7. Login into your Google Analytics account -> Admin -> User Management -> Add permission to your service email address.
43
+ 8. Open [Query Explorer](https://ga-dev-tools.appspot.com/query-explorer/), select your GA account for the project. Note down the number shown after ga. (e.g., ga:xxxxxxxxxx) which is the **GA Profile ID**
44
+
45
+
46
+ ###Configure your Rails application
47
+
48
+ In your Rails application, create a file 'ga_dashboard.rb' inside config/initializers with the following lines
49
+
50
+ ```Ruby
51
+ GA_SERVICE_EMAIL_ADDRESS="<Your Service Email Address>"
52
+ GA_PROFILE_ID="<Ga Profile ID>"
53
+ PATH_TO_KEY_FILE="#{Rails.root}/keys/<Your key file name>"
54
+ ```
55
+
56
+ ###Add code to your controller (e.g., reports_controller#index)
57
+
58
+ ```Ruby
59
+ @ga_dashboard_api=GaDashboard::AnalyticsApi.new("your_project_name",version_no)
60
+ ```
61
+
62
+ ###Add the dashboard in your views
63
+
64
+ In your view file (e.g., reports/index.html.erb) add this
65
+
66
+ ```
67
+ <script src='https://www.google.com/jsapi'></script>
68
+ ```
69
+ * Create the division where you want the dashboard to be appear.
70
+ * Use any of the helper methods listed below to generate the view.
71
+
72
+
73
+ ####1. Popular Pages
74
+
75
+ ```Ruby
76
+ display_most_popular_pages(ga_dashboard_api,pages_starting_with,start_date,end_date,id_of_the_division)
77
+ ```
78
+ #####Example:
79
+
80
+ ```Ruby
81
+ <div id='popular_pages'></div>
82
+ <%= display_most_popular_pages(@ga_dashboard_api,"home",DateTime.now-2.months,DateTime.now,'popular_pages') %>
83
+ ```
84
+
85
+ #####Screenshot
86
+ ![ScreenShot](https://googledrive.com/host/0B-YetaqqmGclN1lzbm1KWGZCekE/popular_pages.png)
87
+
88
+ ####2. Users count from various countries across the world
89
+
90
+ ```Ruby
91
+ display_users_from_countries_across_world(ga_dashboard_api,start_date,end_date,id_of_the_division,format="table",options={})
92
+ ```
93
+
94
+ * format can be either "table" or "map"
95
+ * options - google charts options. [Refer Google Charts Documentation](https://developers.google.com/chart/interactive/docs/customizing_charts)
96
+
97
+ #####Example: Using Map
98
+
99
+ ```Ruby
100
+ <div id='world'></div>
101
+ <%= display_users_from_countries_across_world(@ga_dashboard_api,DateTime.now-2.months,DateTime.now,'world','map',{:title=>'Users Across world'}) %>
102
+ ```
103
+ #####Screenshot
104
+ ![ScreenShot](https://googledrive.com/host/0B-YetaqqmGclN1lzbm1KWGZCekE/world.png)
105
+
106
+ #####Example: Using Table
107
+
108
+ ```Ruby
109
+ <div id='world1'></div>
110
+ <%= display_users_from_countries_across_world(@ga_dashboard_api,DateTime.now-2.months,DateTime.now,'world1','table',{:title=>'Users Across world'}) %>
111
+ ```
112
+ #####Screenshot
113
+ ![ScreenShot](https://googledrive.com/host/0B-YetaqqmGclN1lzbm1KWGZCekE/world_table.png)
114
+
115
+ ####3. Users count from various countries in a continent
116
+ ```Ruby
117
+ display_users_from_countries_of_continent(ga_dashboard_api,continent,start_date,end_date,division_id,format="table",options={})
118
+ ```
119
+ *Acceptable continent names are Africa,Europe,Americas,Asia and Oceania*
120
+
121
+ #####Example: Using Map
122
+
123
+ ```Ruby
124
+ <div id='continent'></div>
125
+ <%= display_users_from_countries_of_continent(@ga_dashboard_api,"Asia",DateTime.now-2.months,DateTime.now,'continent','map',{:title=>"Users from Asia"}) %>
126
+ ```
127
+ #####Screenshot
128
+ ![ScreenShot](https://googledrive.com/host/0B-YetaqqmGclN1lzbm1KWGZCekE/continent.png)
129
+
130
+ ####4. Users count from various cities of a country
131
+ ```Ruby
132
+ display_users_from_cities_of_country(ga_dashboard_api,country,start_date,end_date,id_of_the_division,format="table",options={})
133
+ ```
134
+ *Acceptable country names are listed [here](../Countries.txt?raw=true)*
135
+
136
+ #####Example: Using Map
137
+
138
+ ```Ruby
139
+ <div id='country'></div>
140
+ <%= display_users_from_cities_of_country(@ga_dashboard_api,"India",DateTime.now-2.months,DateTime.now,'country','map',{:title=>"Users from India"}) %>
141
+ ```
142
+ #####Screenshot
143
+ ![ScreenShot](https://googledrive.com/host/0B-YetaqqmGclN1lzbm1KWGZCekE/country.png)
144
+
145
+ ####5. Users Overview
146
+ ```Ruby
147
+ display_users_overview(ga_dashboard_api,start_date,end_date,region_type,region,div_id,options={})
148
+ ```
149
+ * Region Type - Acceptable values are country or continent
150
+ * Region - continent names or countries names basis region type
151
+
152
+ #####Example: Using Map
153
+
154
+ ```Ruby
155
+ <div id='users_overview1'></div>
156
+ <%= display_users_overview(@ga_dashboard_api,DateTime.now-2.months,DateTime.now,'country','India','users_overview1',{:title=>"Users Overview",:height=>'500'}) %>
157
+ ```
158
+ #####Screenshot
159
+ ![ScreenShot](https://googledrive.com/host/0B-YetaqqmGclN1lzbm1KWGZCekE/users_overview1.png)
160
+
161
+ ```Ruby
162
+ <div id='users_overview2'></div>
163
+ <%= display_users_overview(@ga_dashboard_api,DateTime.now-1.months,DateTime.now,'country','India','users_overview2',{:title=>"Users Overview",:height=>'500'}) %>
164
+ ```
165
+ #####Screenshot
166
+ ![ScreenShot](https://googledrive.com/host/0B-YetaqqmGclN1lzbm1KWGZCekE/users_overview2.png)
167
+
168
+ ## Contributing
169
+
170
+ Bug reports and pull requests are welcome on GitHub at https://github.com/renugasaraswathy/ga_dashboard. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](contributor-covenant.org) code of conduct.
171
+
172
+
173
+ ## License
174
+
175
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
176
+
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "ga_dashboard"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
@@ -0,0 +1,7 @@
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+
5
+ bundle install
6
+
7
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,35 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'ga_dashboard/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "ga_dashboard"
8
+ spec.version = GaDashboard::VERSION
9
+ spec.authors = ["Saraswathy Renuga"]
10
+ spec.email = ["renugasaraswathy@gmail.com"]
11
+
12
+ spec.summary = %q{Importing Google Analytics Dashboard into your rails application}
13
+ spec.description = %q{Importing Google Analytics Dashboard into your rails application}
14
+ spec.homepage = ""
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org by setting 'allowed_push_host', or
18
+ # delete this section to allow pushing this gem to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata['allowed_push_host'] = ""
21
+ # else
22
+ # raise "RubyGems 2.0 or newer is required to protect against public gem pushes."
23
+ # end
24
+
25
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
26
+ spec.bindir = "exe"
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ["lib"]
29
+
30
+ spec.add_development_dependency "bundler", "~> 1.10"
31
+ spec.add_development_dependency "rake", "~> 10.0"
32
+ spec.add_development_dependency "rspec"
33
+ spec.add_dependency "google-api-client"
34
+ spec.add_dependency "google_visualr"
35
+ end
@@ -0,0 +1,7 @@
1
+ require "ga_dashboard/version"
2
+ require "ga_dashboard/ga_dashboard_helper"
3
+ require "ga_dashboard/ga_dashboard_api"
4
+ require 'ga_dashboard/railtie' if defined?(Rails)
5
+ module GaDashboard
6
+
7
+ end
@@ -0,0 +1,3 @@
1
+ module GaDashboard
2
+ VERSION = "0.1.0"
3
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: ga_dashboard
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Saraswathy Renuga
9
+ autorequire:
10
+ bindir: exe
11
+ cert_chain: []
12
+ date: 2015-09-10 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: bundler
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: '1.10'
22
+ type: :development
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.10'
30
+ - !ruby/object:Gem::Dependency
31
+ name: rake
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ~>
36
+ - !ruby/object:Gem::Version
37
+ version: '10.0'
38
+ type: :development
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ version: '10.0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :development
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: google-api-client
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: google_visualr
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: Importing Google Analytics Dashboard into your rails application
95
+ email:
96
+ - renugasaraswathy@gmail.com
97
+ executables: []
98
+ extensions: []
99
+ extra_rdoc_files: []
100
+ files:
101
+ - .gitignore
102
+ - .rspec
103
+ - .travis.yml
104
+ - CODE_OF_CONDUCT.md
105
+ - Gemfile
106
+ - LICENSE.txt
107
+ - README.md
108
+ - Rakefile
109
+ - bin/console
110
+ - bin/setup
111
+ - ga_dashboard.gemspec
112
+ - lib/ga_dashboard.rb
113
+ - lib/ga_dashboard/version.rb
114
+ homepage: ''
115
+ licenses:
116
+ - MIT
117
+ post_install_message:
118
+ rdoc_options: []
119
+ require_paths:
120
+ - lib
121
+ required_ruby_version: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ segments:
128
+ - 0
129
+ hash: 549719951
130
+ required_rubygems_version: !ruby/object:Gem::Requirement
131
+ none: false
132
+ requirements:
133
+ - - ! '>='
134
+ - !ruby/object:Gem::Version
135
+ version: '0'
136
+ segments:
137
+ - 0
138
+ hash: 549719951
139
+ requirements: []
140
+ rubyforge_project:
141
+ rubygems_version: 1.8.25
142
+ signing_key:
143
+ specification_version: 3
144
+ summary: Importing Google Analytics Dashboard into your rails application
145
+ test_files: []