Skip to content

Commit

Permalink
feat: update Google Analytics API v3 -> v4
Browse files Browse the repository at this point in the history
  • Loading branch information
rcmdnk committed Sep 14, 2023
1 parent a06d84f commit 74e378a
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 37 deletions.
2 changes: 1 addition & 1 deletion .plugins/octopress-popular-posts
2 changes: 1 addition & 1 deletion .plugins/octopress-share-numbers
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ group :development do
gem 'stringex', '~> 2.8'
gem 'chronic', '~> 0.10'
gem 'gemoji', '~> 2.0'
gem 'google-api-client', '~> 0.53'
gem 'google-analytics-data', '~> 0.4.0'
gem 'htmlcompressor', '~> 0.4'
gem 'jekyll-paginate', '~> 1.1'
gem 'json', '~> 2.6'
Expand Down
24 changes: 10 additions & 14 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -316,22 +316,18 @@ userlocal:

# page-view settings (need service account private key file (key_file). ref: https://github.com/developmentseed/jekyll-ga)
page-view:
service_account_email:
credential:
key_file: # service account private key file (Analytics-XXXXXXXXXXXX.p12)
key_secret: notasecret # service account private key's password
profileID: #ga:XXXXXXXX
property_id: # Analytics property id (XXXXXXXX)
start: # Beginning of report
- 1 month ago
- 10 years ago
- 1 year ago
- 1 week ago
- 1 day ago
end: now # End of report
metric: ga:pageviews # Metric code
segment: gaid::-1 # all visits
filters: # optional
n_posts: 5 # Number of popular posts
show_views: false # If n_views is shown or not
- 30daysAgo
- 3653daysAgo
- 365daysAgo
- 7daysAgo
- 1daysAgo
end: today # End of report
n_posts: 5 # Number of popular posts
show_views: true # If n_views is shown or not
popular_post_title: Most Viewed Posts (Last Month) # Title of sidebar section

# Random posts
Expand Down
2 changes: 1 addition & 1 deletion patches/Gemfile.patch
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ index 5683812..066ef1f 100644
+ gem 'stringex', '~> 2.8'
+ gem 'chronic', '~> 0.10'
+ gem 'gemoji', '~> 2.0'
+ gem 'google-api-client', '~> 0.53'
+ gem 'google-analytics-data', '~> 0.4.0'
+ gem 'htmlcompressor', '~> 0.4'
+ gem 'jekyll-paginate', '~> 1.1'
+ gem 'json', '~> 2.6'
Expand Down
24 changes: 10 additions & 14 deletions patches/_config.yml.patch
Original file line number Diff line number Diff line change
Expand Up @@ -341,22 +341,18 @@ index c1d56f4..d6d2191 100644
+
+# page-view settings (need service account private key file (key_file). ref: https://github.com/developmentseed/jekyll-ga)
+page-view:
+ service_account_email:
+ credential:
+ key_file: # service account private key file (Analytics-XXXXXXXXXXXX.p12)
+ key_secret: notasecret # service account private key's password
+ profileID: #ga:XXXXXXXX
+ property_id: # Analytics property id (XXXXXXXX)
+ start: # Beginning of report
+ - 1 month ago
+ - 10 years ago
+ - 1 year ago
+ - 1 week ago
+ - 1 day ago
+ end: now # End of report
+ metric: ga:pageviews # Metric code
+ segment: gaid::-1 # all visits
+ filters: # optional
+ n_posts: 5 # Number of popular posts
+ show_views: false # If n_views is shown or not
+ - 30daysAgo
+ - 3653daysAgo
+ - 365daysAgo
+ - 7daysAgo
+ - 1daysAgo
+ end: today # End of report
+ n_posts: 5 # Number of popular posts
+ show_views: true # If n_views is shown or not
+popular_post_title: Most Viewed Posts (Last Month) # Title of sidebar section
+
+# Random posts
Expand Down
10 changes: 5 additions & 5 deletions source/posts.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@ share_check_all: true
<div class="share-button">
<ul>
<li><p title="Sort by 1 day views by Analytics"
id="views1d_shuffle" class="btn views1d_custom" >1d views {{site._pv_1-day-ago-to-now}}</p></li>
id="views1d_shuffle" class="btn views1d_custom" >1d views {{site._pv_1daysAgo-to-today}}</p></li>
<li><p title="Sort by 1 week views by Analytics"
id="views1w_shuffle" class="btn views1w_custom" >1w views {{site._pv_1-week-ago-to-now}}</p></li>
id="views1w_shuffle" class="btn views1w_custom" >1w views {{site._pv_7daysAgo-to-today}}</p></li>
<li><p title="Sort by 1 month views by Analytics"
id="views1m_shuffle" class="btn views1m_custom" >1m views {{site._pv_1-month-ago-to-now}}</p></li>
id="views1m_shuffle" class="btn views1m_custom" >1m views {{site._pv_30daysAgo-to-today}}</p></li>
<li><p title="Sort by 1 year views by Analytics"
id="views1y_shuffle" class="btn views1y_custom" >1y views {{site._pv_1-year-ago-to-now}}</p></li>
id="views1y_shuffle" class="btn views1y_custom" >1y views {{site._pv_365daysAgo-to-today}}</p></li>
<li><p title="Sort by 10 years views by Analytics"
id="views10y_shuffle" class="btn views10y_custom" >10y views {{site._pv_10-years-ago-to-now}}</p></li>
id="views10y_shuffle" class="btn views10y_custom" >10y views {{site._pv_3653daysAgo-to-today}}</p></li>
<li><p title="Sort by Hatebu"
id="hatebu_shuffle" class="btn hatebu_custom" >Hatebu {{site.hatebuCount}}</p></li>
<li><p title="Sort by Tweet"
Expand Down

0 comments on commit 74e378a

Please sign in to comment.