Advertise with Googlier.com
グロースエンジニアのブログ
https://31webcreation.hatenablog.com/
Ruby on Rails エンジニアです!開発に当たって勉強したことをまとめていこうと思います!
Mon, 12 Jun 2023 22:30:51 +0900
http://blogs.law.harvard.edu/tech/rss
Hatena::Blog
-
レガシーコードの改善は事前に経営陣とスケジュール、リソースの調整をしてから行うと良さそう
https://31webcreation.hatenablog.com/entry/2023/06/12/223051 <p><iframe sandbox="allow-popups allow-scripts allow-modals allow-forms allow-same-origin" style="width: 120px; height: 240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="//rcm-fe.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=taigi-factory-22&language=ja_JP&o=9&p=8&l=as4&m=amazon&f=ifr&ref=as_ss_li_til&asins=4863544103&linkId=a1faec167e8178066255ff7369a1e718"></iframe></p>
<p> </p>
<p>本書ではレガシーコードを以下と定義しています。</p>
<blockquote>
<p>創業期の資金不足や人材不足によって生じたコード上の課題全般を、広義のレガシーコードと定義し、使用します。</p>
</blockquote>
<p>レガシーコードへの本って方法的な話が多いが、この本ではそもそも会社は事業計画があって、技術的負債も含めてレガシーコードへの対応は経営陣と協調して進める必要があると書いてあって、僕としては初めて見た内容でこの視点はとても勉強になりました。</p>
<p> </p>
<p>お金の視点は欠けていて、金銭面で見たときの会社の生存期間(ランウェイ)を計算し、人を●人採用すれば毎月の支出が増えるのでランウェイがこのくらい短くなって...といったことを考えたことがなかったので、それを知れただけでも読む価値があったなと思います。</p>
<p> </p>
<h3 id="経営陣への3つの提案">経営陣への3つの提案</h3>
<p>レガシーコードへの対応として以下の3つのパターンがある</p>
<ul>
<li>現状のままいく</li>
<li><a class="keyword" href="https://d.hatena.ne.jp/keyword/%A5%EA%A5%D5%A5%A1%A5%AF%A5%BF%A5%EA%A5%F3%A5%B0">リファクタリング</a>する</li>
<li>リプレイスする</li>
</ul>
<p>それぞれのパターンで人を増やすことも踏まえて人件費がどのくらいかかるかを見積もりして、経営陣と相談する</p>
<h3 id="レガシーコードへの対応">レガシーコードへの対応</h3>
<p>レガシーコードと言っても不具合発生率、開発効率、技術的負債、デプロイ頻度など様々なものがあり、今一番困っているもの、改善して効果が大きいものを見極め、それに合わせた採用だったり人の割当をする必要がある</p>
<h3 id="まとめ">まとめ</h3>
<p>技術的な方法としてレガシーコードへの対応をこの本に期待すると違うが、経営陣と会話して何を進めていくのか決めているようなエンジニアには良い本だと思う。</p>
<p>そうでなくても、こういった視点を持って会社を経営しているということが分かってとても勉強になった。</p>
<p>技術的な部分はざっくりとした解説になっているので、そこを自分で埋めていこうと思う。</p>
<p> </p>
<p><iframe sandbox="allow-popups allow-scripts allow-modals allow-forms allow-same-origin" style="width: 120px; height: 240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="//rcm-fe.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=taigi-factory-22&language=ja_JP&o=9&p=8&l=as4&m=amazon&f=ifr&ref=as_ss_li_til&asins=4863544103&linkId=a1faec167e8178066255ff7369a1e718"></iframe></p> Mon, 12 Jun 2023 22:30:51 +0900
hatenablog://entry/820878482941135385
-
リーンとはフロー効率を優先する絶え間ない改善である
https://31webcreation.hatenablog.com/entry/2023/06/08/210548 <p>This is Lean という本を読んでとても良かったので忘れないうちにまとめておこうと思う</p>
<p> </p>
<p><iframe sandbox="allow-popups allow-scripts allow-modals allow-forms allow-same-origin" style="width: 120px; height: 240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="//rcm-fe.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=taigi-factory-22&language=ja_JP&o=9&p=8&l=as4&m=amazon&f=ifr&ref=as_ss_li_til&asins=479816951X&linkId=a34acdcd9da5a942b911436c001f3bce"></iframe></p>
<p> </p>
<h3 id="リーンとはフロー効率を優先する絶え間ない改善である">リーンとはフロー効率を優先する絶え間ない改善である</h3>
<p>タイトルにも書いたけど、これが本書で言いたいことだと思う。</p>
<p>最初にいい例があって、これを頭に入れておくとその後の話が入って来やすい。</p>
<p> </p>
<h3 id="リソース効率とフロー効率">リソース効率とフロー効率</h3>
<p>リソース効率とは、サービスにおいてサービスを提供する側のリソースの効率のこと。</p>
<p>本の例では胸のしこりを見つけた患者が最初に行った病院では結果が分からず、その後複数病院を回って結果が出たのが2ヶ月後という内容。</p>
<p>これは各病院でできることに対してリソースを効率化しているために起こっている。</p>
<p>フロー効率とは、サービスを受ける側のニーズを満たす効率のこと。</p>
<p>胸のしこりがあって<a class="keyword" href="https://d.hatena.ne.jp/keyword/%C6%FD%A4%AC%A4%F3">乳がん</a>専門の病院に行くと、そのニーズに応えることに特化したリソースが準備されており数時間で結果がわかる。</p>
<p>これはサービスを受ける側のニーズを最短で満たしている。</p>
<h3 id="スループット時間"><a class="keyword" href="https://d.hatena.ne.jp/keyword/%A5%B9%A5%EB%A1%BC%A5%D7%A5%C3%A5%C8">スループット</a>時間</h3>
<p>上記の例で患者をフローユニットと呼ぶ。フローユニットとは、リソースが価値を付加する対象のこと。</p>
<p>このフローユニットがニーズに気づいてから、それを満たすまでの時間を<a class="keyword" href="https://d.hatena.ne.jp/keyword/%A5%B9%A5%EB%A1%BC%A5%D7%A5%C3%A5%C8">スループット</a>時間と呼び、フロー効率を高めるとこの時間が短くなり、リソース効率を高めるとこの時間が長くなっていくというもの。</p>
<h3 id="リソース効率化によってスループット時間が長くなる">リソース効率化によって<a class="keyword" href="https://d.hatena.ne.jp/keyword/%A5%B9%A5%EB%A1%BC%A5%D7%A5%C3%A5%C8">スループット</a>時間が長くなる</h3>
<p>病院の例で患者はニーズを満たすまで2ヶ月かかっている。これは最初のニーズが発生してすぐに解決できないことによって別のニーズ(別の病院に行って検査が必要)が発生している状態。</p>
<p>1つの病院で全て終われば発生しなかったことであり、2ヶ月という期間によって患者は不安な2ヶ月を過ごさねばならないため、さらなるニーズ(不安)を発生させている。</p>
<h3 id="フロー効率を優先する">フロー効率を優先する</h3>
<p>フロー効率を優先することで患者はすぐに結果がわかり、時間的に早く、メンタル的にも不安な日々を送らなくてよくなる(結果が早く出すぎて心の準備が...という話も本では上がっていた)</p>
<h3 id="開発で考えるとフロー効率はリリースまでの時間の短縮化">開発で考えるとフロー効率はリリースまでの時間の短縮化</h3>
<p>ふと自分たちの開発に当てはめてみるとフロー効率は機能リリースまでの時間を以下に短くしていくかだなと感じた。</p>
<p>フロー効率を上げるには、仕様ぎめ、実装、レビュー、リリースまでの時間の短縮と考えると、例えば実装に時間がかかっているのは仕様に曖昧なところが残っているのでは?とか、レビューに時間がかかっているのは Pull Request 自体が大きかったり、タスクの細分化がうまくできてなかったりなど、改善する視点がいろいろと出てくるんじゃないかなと感じた。</p>
<h3 id="まとめ">まとめ</h3>
<p>フロー効率という視点を得たことで、自分の開発フローをどう改善すると良くなるか考える新しい視点が加わった気がする。</p>
<p>あと、本の最初の例がそれ以降の話の全ての具体例になっていて理解しやすい構造になっていたのも良かった。</p>
<p>開発体制をもっと良くしていくためにチームメンバーと共有してもっといいチームにできるようにしていきたい。</p>
<p> </p>
<p><iframe sandbox="allow-popups allow-scripts allow-modals allow-forms allow-same-origin" style="width: 120px; height: 240px;" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" src="//rcm-fe.amazon-adsystem.com/e/cm?lt1=_blank&bc1=000000&IS2=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=taigi-factory-22&language=ja_JP&o=9&p=8&l=as4&m=amazon&f=ifr&ref=as_ss_li_til&asins=479816951X&linkId=a34acdcd9da5a942b911436c001f3bce"></iframe></p>
<p> </p> Thu, 08 Jun 2023 21:05:48 +0900
hatenablog://entry/820878482939881808
-
factory_bot 再入門
https://31webcreation.hatenablog.com/entry/2018/04/03/100032 <p><a class="keyword" href="http://d.hatena.ne.jp/keyword/Rails">Rails</a>を始めてはや数年、最初のころに factory_girl の勉強をして、それ以来必要に合わせてちょっと調べて終わりって感じで過ごしてきた。</p>
<p>最近<a class="keyword" href="http://d.hatena.ne.jp/keyword/Rails">Rails</a>を始めた人に、「<a class="keyword" href="http://d.hatena.ne.jp/keyword/Rails">Rails</a><a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C1%A5%E5%A1%BC%A5%C8%A5%EA%A5%A2%A5%EB">チュートリアル</a>とかeveryday <a class="keyword" href="http://d.hatena.ne.jp/keyword/rails">rails</a>とかやって、開発してるプロダクト見ると書き方が違ってる」って話を聞き、そう言えばその辺の知識って古いまま(と言っても2,3年前?)更新されてないな...と思って読み直すと結構知らなかったことが多かった。</p>
<p>なので、ざっとまとめてみる。</p>
<p>まとめる内容は全部ここに書いてるので、こちらを見るとよいかと!</p>
<p><iframe class="embed-card embed-webcard" style="display: block; width: 100%; height: 155px; max-width: 500px; margin: 10px 0px;" title="thoughtbot/factory_bot" src="https://hatenablog-parts.com/embed?url=https%3A%2F%2Fgithub.com%2Fthoughtbot%2Ffactory_bot%2Fblob%2Fmaster%2FGETTING_STARTED.md" frameborder="0" scrolling="no"></iframe><cite class="hatena-citation"><a href="https://github.com/thoughtbot/factory_bot/blob/master/GETTING_STARTED.md">github.com</a></cite></p>
<h3>attributes_for</h3>
<p>これも地味に知らなかった。</p>
<pre><code># Returns a hash of attributes that can be used to build a User instance
attrs = attributes_for(:user)</code></pre>
<h3>Aliases</h3>
<p>Factory に alias が付けれる</p>
<pre><code>factory :user, aliases: [:author, :commenter] do
first_name "John"
last_name "Doe"
date_of_birth { 18.years.ago }
end
factory :post do
author
# instead of
# association :author, factory: :user
title "How to read a book effectively"
body "There are five steps involved."
end
factory :comment do
commenter
# instead of
# association :commenter, factory: :user
body "Great article!"
end</code></pre>
<p>はい、知りませんでした...</p>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%DD%A5%EA%A5%E2%A1%BC%A5%D5%A5%A3%A5%C3%A5%AF">ポリモーフィック</a>とか使ってるのをちょいちょい見るので、これ使うとわかりやすくなるかな〜とか思ったり。</p>
<h3>Transient Attributes</h3>
<p>ちょいちょい見て、わかってるようで分かってなかった。 </p>
<p>この例はわかりやすくて、理解できた。</p>
<pre><code>factory :user do
transient do
rockstar true
upcased false
end
name { "John Doe#{" - Rockstar" if rockstar}" }
email { "#{name.downcase}@example.com" }
after(:create) do |user, evaluator|
user.name.upcase! if evaluator.upcased
end
end
create(:user, upcased: true).name
#=> "JOHN DOE - ROCKSTAR"</code></pre>
<h3>Inheritance</h3>
<p>いつも trait を使ってたけど、こういうのもあるのか。一回で書けるって意味ではいいのかもな。</p>
<pre><code>factory :post do
title "A title"
factory :approved_post do
approved true
end
end
approved_post = create(:approved_post)
approved_post.title # => "A title"
approved_post.approved # => true</code></pre>
<pre><code>factory :post do
title "A title"
end
factory :approved_post, parent: :post do
approved true
end</code></pre>
<h3><span style="color: #24292e; font-family: -apple-system, system-ui, 'Segoe UI', Helvetica, Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol'; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">Associations</span></h3>
<p>alias を使えばいいけど、こういう書き方もある。</p>
<pre><code>factory :post do
# ...
association :author, factory: :user, last_name: "Writely"
end</code></pre>
<h3>Sequences</h3>
<p>こうやって別個に定義できるってのは知らなかったな。</p>
<pre><code># Defines a new sequence
FactoryBot.define do
sequence :email do |n|
"person#{n}@example.com"
end
end
generate :email
# => "person1@example.com"
generate :email
# => "person2@example.com"</code></pre>
<pre><code>factory :invite do
invitee { generate(:email) }
end</code></pre>
<pre><code>factory :user do
email # Same as `email { generate(:email) }`
end</code></pre>
<p>んで、aliasも定義できる</p>
<pre><code>factory :user do
sequence(:email, 1000, aliases: [:sender, :receiver]) { |n| "person#{n}@example.com" }
end
# will increase value counter for :email which is shared by :sender and :receiver
generate(:sender)</code></pre>
<h3><code>Linting Factories</code></h3>
<p>Lint ってよくあるけど、factory_<a class="keyword" href="http://d.hatena.ne.jp/keyword/bot">bot</a> でもあるって知らなかった。</p>
<p>「うるせー!」 って言いたくなることもあるけど(笑)</p>
<pre><code>FactoryBot.lint</code></pre>
<h3>まとめ</h3>
<p>これ以外にもいろいろ紹介されてたけど、基本的なところはこんなところかなと!</p>
<p>gemも定期的に見て、機能とか確認していかないとダメだなというのが今回の気付き!</p>
<p><iframe class="embed-card embed-webcard" style="display: block; width: 100%; height: 155px; max-width: 500px; margin: 10px 0px;" title="thoughtbot/factory_bot" src="https://hatenablog-parts.com/embed?url=https%3A%2F%2Fgithub.com%2Fthoughtbot%2Ffactory_bot%2F" frameborder="0" scrolling="no"></iframe><cite class="hatena-citation"><a href="https://github.com/thoughtbot/factory_bot/">github.com</a></cite></p> Tue, 03 Apr 2018 10:00:32 +0900
hatenablog://entry/17391345971631876093
Rails
test
factory_bot
-
【mastodon】bundle install でエラーが出たのでメモしておく
https://31webcreation.hatenablog.com/entry/2018/03/26/223926 <p><a class="keyword" href="http://d.hatena.ne.jp/keyword/mastodon">mastodon</a> がちょっと前に流行ってコード読もう読もうと思ってそのままにしていたので、時間取れるときに読もうと思って bundle install したらエラーになったのでメモ。</p>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/mastodon">mastodon</a> のバージョンは 2.3.2 </p>
<h3>Failed to locate protobuf</h3>
<pre><code>current directory:
/mastodon/vendor/bundle/ruby/2.5.0/gems/cld3-3.2.2/ext/cld3
.rbenv/versions/2.5.0/bin/ruby -r ./siteconf20180326-69724-1yq4plx.rb extconf.rb
Failed to locate protobuf
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/mastodon/vendor/bundle/ruby/2.5.0/extensions/x86_64-darwin-16/2.5.0-static/cld3-3.2.2/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
/mastodon/vendor/bundle/ruby/2.5.0/gems/cld3-3.2.2 for inspection.
Results logged to
/mastodon/vendor/bundle/ruby/2.5.0/extensions/x86_64-darwin-16/2.5.0-static/cld3-3.2.2/gem_make.out
An error occurred while installing cld3 (3.2.2), and Bundler cannot continue.
Make sure that `gem install cld3 -v '3.2.2'` succeeds before bundling.</code></pre>
<p>`gem install cld3 -v '3.2.2'` をやってみたけどダメで、調べたら protobuf なるものが必要みたいで、 `<a class="keyword" href="http://d.hatena.ne.jp/keyword/brew">brew</a> install protobuf` をやったら通った!</p>
<p> つづいてこちら</p>
<h3>ERROR: could not find idn library!</h3>
<pre><code>current directory:
/mastodon/vendor/bundle/ruby/2.5.0/gems/idn-ruby-0.1.0/ext
/.rbenv/versions/2.5.0/bin/ruby -r ./siteconf20180326-5783-ruj5ss.rb extconf.rb
checking for -lidn... no
ERROR: could not find idn library!
Please install the GNU IDN library or alternatively specify at least one
of the following options if the library can only be found in a non-standard
location:
--with-idn-dir=/path/to/non/standard/location
or
--with-idn-lib=/path/to/non/standard/location/lib
--with-idn-include=/path/to/non/standard/location/include
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of necessary
libraries and/or headers. Check the mkmf.log file for more details. You may
need configuration options.
Provided configuration options:
--with-opt-dir
--without-opt-dir
--with-opt-include
--without-opt-include=${opt-dir}/include
--with-opt-lib
--without-opt-lib=${opt-dir}/lib
--with-make-prog
--without-make-prog
--srcdir=.
--curdir
--ruby=.rbenv/versions/2.5.0/bin/$(RUBY_BASE_NAME)
--with-idn-dir
--without-idn-dir
--with-idn-include
--without-idn-include=${idn-dir}/include
--with-idn-lib
--without-idn-lib=${idn-dir}/lib
--with-idnlib
--without-idnlib
To see why this extension failed to compile, please check the mkmf.log which can be found here:
/mastodon/vendor/bundle/ruby/2.5.0/extensions/x86_64-darwin-16/2.5.0-static/idn-ruby-0.1.0/mkmf.log
extconf failed, exit code 1
Gem files will remain installed in
/mastodon/vendor/bundle/ruby/2.5.0/gems/idn-ruby-0.1.0 for inspection.
Results logged to
/mastodon/vendor/bundle/ruby/2.5.0/extensions/x86_64-darwin-16/2.5.0-static/idn-ruby-0.1.0/gem_make.out
An error occurred while installing idn-ruby (0.1.0), and Bundler cannot continue.
Make sure that `gem install idn-ruby -v '0.1.0'` succeeds before bundling.</code></pre>
<p>これも <a class="keyword" href="http://d.hatena.ne.jp/keyword/brew">brew</a> install libidn したら通った。</p>
<p> </p> Mon, 26 Mar 2018 22:39:26 +0900
hatenablog://entry/17391345971629713154
mastodon
Rails
-
第57回 Ginza.rbに行ってきた!
https://31webcreation.hatenablog.com/entry/2018/03/21/133018 <p>今回は【ディスカッションプラットフォーム Discourse のソースを読もう!】というテーマでした。</p>
<p><iframe class="embed-card embed-webcard" style="display: block; width: 100%; height: 155px; max-width: 500px; margin: 10px 0px;" title="discourse/discourse" src="https://hatenablog-parts.com/embed?url=https%3A%2F%2Fgithub.com%2Fdiscourse%2Fdiscourse" frameborder="0" scrolling="no"></iframe><cite class="hatena-citation"><a href="https://github.com/discourse/discourse">github.com</a></cite></p>
<p> </p>
<p>今回も忘れないうちにメモしたことをまとめます。</p>
<p> </p>
<h3>Discourseとは?</h3>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%AA%A1%BC%A5%D7%A5%F3%A5%BD%A1%BC%A5%B9">オープンソース</a>として公開されている掲示板やチャットが使えるディスカッションプラットフォームで、現場感のあるコードとのこと!</p>
<p>フロントは Ember で作られている。</p>
<p>スピードを気にしていて、○○族な人が作ってるらしい。</p>
<h3>勉強会メモ</h3>
<p>メモした内容をざっと記録していく!</p>
<h4>lib にいろいろ詰め込んてる</h4>
<p>アプリとは切り離して動くコードがここにある。</p>
<p><span style="color: #4d4d4d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Hiragino Kaku Gothic ProN', Meiryo, 'Segoe UI Symbol', sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">lib/freedom_patches ってのがあって、これを自分たちのアプリでも作って、公開できるやつは公開していくのはいい方法。</span></p>
<p><a href="https://github.com/discourse/discourse/tree/master/lib/freedom_patches">discourse/lib/freedom_patches at master · discourse/discourse · GitHub</a></p>
<h4>コントローラーで require している</h4>
<p>スピードに気をつけているので、必要に合わせてコントローラーなどで require している</p>
<p><a href="https://github.com/discourse/discourse/tree/master/app/controllers">discourse/app/controllers at master · discourse/discourse · GitHub</a></p>
<h4><span style="color: #4d4d4d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Hiragino Kaku Gothic ProN', Meiryo, 'Segoe UI Symbol', sans-serif;">モデルに置けないものを services に置いてる</span></h4>
<p>処理系のメソッドをここにまとめて定義している感じ</p>
<p><a href="https://github.com/discourse/discourse/tree/master/app/services">discourse/app/services at master · discourse/discourse · GitHub</a></p>
<h4><a class="keyword" href="http://d.hatena.ne.jp/keyword/%B4%C4%B6%AD%CA%D1%BF%F4">環境変数</a>のデフォルト値を上げてパフォーマンスを上げてる</h4>
<p><a href="https://github.com/discourse/discourse/blob/master/script/bench.rb">discourse/bench.rb at master · discourse/discourse · GitHub</a></p>
<h4>pluck, present?, blank? を早くしてる</h4>
<p><a href="https://github.com/discourse/discourse/blob/master/lib/freedom_patches/fast_pluck.rb">discourse/fast_pluck.rb at master · discourse/discourse · GitHub</a></p>
<p><a href="https://github.com/discourse/discourse/blob/master/lib/freedom_patches/performance_fixes.rb">discourse/performance_fixes.rb at master · discourse/discourse · GitHub</a></p>
<h4>その他</h4>
<p>- Gemfile も Discource 自身が作っているものがあり、スピードを気にして使っている</p>
<p> </p>
<p>- 参考にするのはどのサイトが良い?</p>
<p>-> 過去の歴史を見るという意味で readmine</p>
<p><a href="https://github.com/redmine/redmine">GitHub - redmine/redmine: Mirror of redmine code source - Official SVN repository is at https://svn.redmine.org/redmine - contact: @jbbarth or jeanbaptiste.barth (at) gmail (dot) com</a></p>
<p> </p>
<p>-> <a class="keyword" href="http://d.hatena.ne.jp/keyword/mastodon">mastodon</a></p>
<p><a href="https://github.com/tootsuite/mastodon">GitHub - tootsuite/mastodon: Your self-hosted, globally interconnected microblogging community</a></p>
<p> </p>
<p>-> discource は現場感があっていい</p>
<p><a href="https://github.com/discourse/discourse">GitHub - discourse/discourse: A platform for community discussion. Free, open, simple.</a></p>
<p> </p>
<p>- <span style="color: #4d4d4d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Hiragino Kaku Gothic ProN', Meiryo, 'Segoe UI Symbol', sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">TracePoint がキテるらしい</span></p>
<h3>まとめ</h3>
<p>頑張って話を聞き逃さないようにメモ取ってたけど、理解しようとして考えてて取りきれてない部分が結構ある気がする...</p>
<p>でも、今回も自分の知らないことがたくさん聞けて学ぶことも多かった。</p>
<p>少しでも内容を理解して自分の力にできるように、今後も参加していこうと思います!</p> Wed, 21 Mar 2018 13:30:18 +0900
hatenablog://entry/17391345971627831516
Rails
勉強会
-
第56回 Ginza.rbに行ってきた!
https://31webcreation.hatenablog.com/entry/2018/02/21/142220 <p>ここ数ヶ月続けて Ginza.rb に参加しています。</p>
<p>自分とのレベルが違いすぎて圧倒されることが多いんですが、このままだと本当にただ参加しているだけになってしまうので、振り返りもかねて学んだことを記録して行こうと思います。</p>
<h3>今回のテーマ</h3>
<p>【第56回 もうすぐやってくる!Rails5.<wbr />2の細かいところも見ておこう 】ということで、資料はこちら!(公開してもいいということだったので大丈夫なはず!)</p>
<p><a href="https://y-yagi.github.io/presen_rails_5_2_part2/#/">Rails 5.2</a></p>
<p>内容については<a class="keyword" href="http://d.hatena.ne.jp/keyword/%BE%E5%B5%AD">上記</a>資料を見た方がいいです。</p>
<p>各ページの青いところはリンクになっていて関連するPRなどに飛べるので分かりやすいと思います。(さすが、あの方の資料!)</p>
<p>以下、自分用のメモ。<br />知らなかった機能などはざっとどんな機能か調べてリンクを貼ってます。</p>
<p>(間違いなどあればご指摘いただけるとうれしいです!)</p>
<h4>Action Cable</h4>
<p>- hostとかportとかを設定できるようになった</p>
<p>使ったことないけど、今後機会があれば思い出せるようにメモ。</p>
<h4>Action Mailer</h4>
<p>- Mailer ごとに delivery job を設定できる</p>
<p>`delivery_later` したときに呼ばれるjobを自由に設定できるってことかな?</p>
<p><a href="https://github.com/rails/rails/blob/2b35826389005bdb0af85a4ebb1f0ec213174d13/actionmailer/test/message_delivery_test.rb#L66">rails/message_delivery_test.rb at 2b35826389005bdb0af85a4ebb1f0ec213174d13 · rails/rails · GitHub</a></p>
<p><br />- email preview にlocaleが選べるようになった</p>
<p>preview 機能自体を知らなかった...。<br /><cite class="hatena-citation"></cite></p>
<p><a href="https://qiita.com/port-development/items/ce30e580da064de07b4a">ActionMailer Preview のススメ - Qiita</a></p>
<p><a href="http://y-yagi.tumblr.com/post/88746017105/rails%E3%81%AEaction-mailer-previews%E3%81%AB%E3%81%A4%E3%81%84%E3%81%A6">RailsのAction Mailer Previewsについて | 日々雑記</a></p>
<h4>Action Pack</h4>
<p>- cache key と cache version(updated_at)を分けて管理し、 cache keyを再利用可能に</p>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/Rails">Rails</a> の version up のときに、load default にするとあれするので気を付けてね!とのこと。</p>
<p>ローカルで試すには設定が必要っぽい。</p>
<blockquote>
<p><span style="color: #333333; font-family: Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">キャッシュは、デフォルトではproduction環境でのみ有効になります。ローカルでキャッシュを使ってみたい場合は、対応する</span><code style="margin: 1.5em 0px; padding: 0px; border: 0px; outline: 0px; font-size: 14px; background: #ffffff; font-family: 'Anonymous Pro', Inconsolata, Menlo, Consolas, 'Bitstream Vera Sans Mono', 'Courier New', monospace; line-height: 1.5; overflow: auto; color: #222222; white-space: pre-wrap; word-wrap: break-word; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">config/environments/*.rb</code><span style="color: #333333; font-family: Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">ファイルで</span><code style="margin: 1.5em 0px; padding: 0px; border: 0px; outline: 0px; font-size: 14px; background: #ffffff; font-family: 'Anonymous Pro', Inconsolata, Menlo, Consolas, 'Bitstream Vera Sans Mono', 'Courier New', monospace; line-height: 1.5; overflow: auto; color: #222222; white-space: pre-wrap; word-wrap: break-word; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">config.action_controller.perform_caching</code><span style="color: #333333; font-family: Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">を</span><code style="margin: 1.5em 0px; padding: 0px; border: 0px; outline: 0px; font-size: 14px; background: #ffffff; font-family: 'Anonymous Pro', Inconsolata, Menlo, Consolas, 'Bitstream Vera Sans Mono', 'Courier New', monospace; line-height: 1.5; overflow: auto; color: #222222; white-space: pre-wrap; word-wrap: break-word; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; text-decoration-style: initial; text-decoration-color: initial;">true</code><span style="color: #333333; font-family: Helvetica, Arial, sans-serif; font-size: 14px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: 2; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; text-decoration-style: initial; text-decoration-color: initial; display: inline !important; float: none;">に設定します。</span></p>
</blockquote>
<p><a href="https://railsguides.jp/caching_with_rails.html">Rails のキャッシュ: 概要 | Rails ガイド</a></p>
<p>- eager_load = true の場合、サーバー起動時に各コントローラーのactionを読み込むようになった</p>
<p>- encrypted cookies に AES-256-GCM を使用</p>
<p>より堅牢なものになった<br /><a class="keyword" href="http://d.hatena.ne.jp/keyword/Rails">Rails</a>側で良いようにしてくれる(自動で書き換える)<br />勝手に古いcookies を新しいものに書き換える</p>
<p>- protect_from_forgery がデフォルトになった</p>
<p>- signed/encrypted cookiesに有効期限を知っていできる</p>
<p>- key の rotation ができるようになった</p>
<pre><code># ここで新しいものを指定
Rails.application.config.action_dispatch.signed_cookie_digest = "SHA256"
# ここで古いのを指定
Rails.application.config.action_dispatch.cookies_rotations.tap do |cookies|
cookies.rotate :signed, digest: "SHA1"
end</code></pre>
<p>- System test に headless <a class="keyword" href="http://d.hatena.ne.jp/keyword/chrome">chrome</a> driver, headless <a class="keyword" href="http://d.hatena.ne.jp/keyword/firefox">firefox</a> driver が入った</p>
<p>- デフォルトの <a class="keyword" href="http://d.hatena.ne.jp/keyword/mime">mime</a> type が追加された</p>
<p>- header が変わった<br />以下の3つが追加された</p>
<pre><code>
"X-Download-Options" => "noopen",
"X-Permitted-Cross-Domain-Policies" => "none",
"Referrer-Policy" => "strict-origin-when-cross-origin"
</code></pre>
<h4>Action View</h4>
<p>- srcset を指定できるようになった</p>
<p>- 画像の alt の自動生成を削除</p>
<p>- form_with に id 属性を追加するようになった<br />capybara のテストなどで必要ということで追加された </p>
<h4>Active Job</h4>
<p>jobを実行する際にオブジェクトを<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%B7%A5%EA%A5%A2%A5%E9%A5%A4%A5%BA">シリアライズ</a>、デ<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%B7%A5%EA%A5%A2%A5%E9%A5%A4%A5%BA">シリアライズ</a>してる。<br />それを自分で定義できるようになった</p>
<h4>Active Model</h4>
<p>- length validatorにProc, Symbolが渡せるようになった<br />これにより、条件を指定して最大文字数とかを調整できるようになった</p>
<p>- Active Record にあった attributes <a class="keyword" href="http://d.hatena.ne.jp/keyword/API">API</a> が Active Model 配下に移動<br />Active Record のものを使うのは問題ない<br />Active Model のものは public ではない</p>
<p>(<a class="keyword" href="http://d.hatena.ne.jp/keyword/Rails">Rails</a> で public <a class="keyword" href="http://d.hatena.ne.jp/keyword/api">api</a> ってのは docs にあるかどうか)</p>
<h4>Active Record</h4>
<p>- Descending Indexが指定できるようになった(<a class="keyword" href="http://d.hatena.ne.jp/keyword/MySQL">MySQL</a> 8.0.1以降)</p>
<p>- sqlite3 で boolean を t/f から 1/0 に修正<br />t/f で保存していた場合、手動で変更する必要がある</p>
<p>- order と pluck に生 <a class="keyword" href="http://d.hatena.ne.jp/keyword/SQL">SQL</a> はダメ<br />Arel.<a class="keyword" href="http://d.hatena.ne.jp/keyword/sql">sql</a>メソッドでラップしないとだめ</p>
<p>- fixtures でまとめてクエリーを実行するようになった</p>
<p>- <a class="keyword" href="http://d.hatena.ne.jp/keyword/SQL">SQL</a>が発行された場所が log に出るようになった<br />デフォルトは開発環境のみ</p>
<p>- <a class="keyword" href="http://d.hatena.ne.jp/keyword/MySQL">MySQL</a> の bulk true があったけど、 <a class="keyword" href="http://d.hatena.ne.jp/keyword/PostgreSQL">PostgreSQL</a> でもできるようになった</p>
<p>- <a class="keyword" href="http://d.hatena.ne.jp/keyword/PostgreSQL">PostgreSQL</a> の foreign tables をサポート</p>
<p>- Errorクラスが増えてる</p>
<p><a href="https://y-yagi.github.io/presen_rails_5_2_part2/#/47">https://y-yagi.github.io/presen_rails_5_2_part2/#/47</a></p>
<p>- その他、 Active Record はこれを見ると良い<br /><a href="http://kamipo.github.io/talks/20180215-tdtech/#/title">http://kamipo.github.io/talks/20180215-tdtech/#/title</a></p>
<h4>Atcive Support</h4>
<p>- Date#prev_occurring、Date#next_occurringメソッドが追加された<br />前の曜日、次の曜日を取得するメソッド</p>
<p>- <a class="keyword" href="http://d.hatena.ne.jp/keyword/ActiveSupport">ActiveSupport</a>::Cache::Store に write_multi メソッドを追加<br />Redis adapterだとMSETを使うようになるので、一個一個書き込むよりはやい</p>
<p>- <a class="keyword" href="http://d.hatena.ne.jp/keyword/ActiveSupport">ActiveSupport</a>::Testing::TimeHelpersをincludeしている場合、テストの後処理で自動でtravel_backが呼ばれるようになった<br /><a class="keyword" href="http://d.hatena.ne.jp/keyword/Rspec">Rspec</a> はどうするのかわからない</p>
<h4><a class="keyword" href="http://d.hatena.ne.jp/keyword/Railties">Railties</a></h4>
<p>- <a class="keyword" href="http://d.hatena.ne.jp/keyword/rails">rails</a> new 時の Gemfile に bootsnap を追加</p>
<p>--skip-bootsnap でスキップできる</p>
<h3>その後の飲み会</h3>
<p>今回は知った人が多かったので飲み会にも参加!</p>
<p>自分の開発経験にはない話がいっぱい出てきて、とても勉強になった。前に一回参加したときも感じたけど、こういう中での話にも知らないことがいっぱい出てくるので聞いてるだけで楽しい!</p>
<p>また参加します!</p> Wed, 21 Feb 2018 14:22:20 +0900
hatenablog://entry/17391345971618379622
Rails
勉強会
-
2017年を振り返って
https://31webcreation.hatenablog.com/entry/2017/12/30/142455 <p>今年は一年マルっと<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%D5%A5%EA%A1%BC%A5%E9%A5%F3%A5%B9">フリーランス</a> <a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%D7%A5%ED%A5%B0%A5%E9%A5%DE%A1%BC">プログラマー</a>として活動した年だった。</p>
<p>周りの人には言っているが、リサーチをやっていたときには全く考えていない働き方だし、こんなに楽しく仕事ができるようになったのも想像してなかったので、今の気持ちを整理したいと思う。</p>
<h3>フリーになりたてのころ</h3>
<p>正確には、去年(2016年)の10月からフリーになった。</p>
<p>当初はリサーチ業界から転職して<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%D7%A5%ED%A5%B0%A5%E9%A5%DE%A1%BC">プログラマー</a>としての仕事は2年くらいで不安しかなかった。</p>
<ul>
<li>こんなんで仕事できるの?</li>
<li>コード理解できるかな?</li>
<li>コード書けるかな?</li>
</ul>
<p>この時期は、まだ<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%D7%A5%ED%A5%B0%A5%E9%A5%DE%A1%BC">プログラマー</a>なりたてだし...って自分に言い訳をしてたのもあった。</p>
<h3>一年を振り返った今の気持ち</h3>
<p>この一年で合計3社さんとお仕事させてもらって、不安は少しずつ減ってきた。</p>
<p>それぞれの会社さんで実装面で相談にのってもらったり、知識不足のところは教えてもらったり、たくさんの人に助けてもらって、それまで「俺にできるのか?」って思ってたことでも「何とかできそう!」って思えるようになってきた。</p>
<p>今でも不安な気持ちはあるし、アウトプット出せてないときは本当に申し訳なく思う。だからこそ、もっと勉強しないといけないと思うし、期待されて、その期待以上のものを出す<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%D7%A5%ED%A5%B0%A5%E9%A5%DE%A1%BC">プログラマー</a>になりたいなと思う。</p>
<p>いつからこんなに勉強することが楽しくなったのか、自分でも不思議なくらい本を読んだりコードを書くようになったのも事実で、まだまだ楽しく仕事できるな〜って感じている。</p>
<p>(それぞれの会社でお世話になった方々、ありがとうございました。)</p>
<h3>反省点</h3>
<p>性格的に怖がりで失敗したくないので、今ある知識の中で何とかしようとする部分が多かった。</p>
<p>でも、一回経験しておくと二回目以降に安心して手が動くという経験を何度もしたので、新しく勉強したものを「何でそれがいいのか?」という部分をちゃんと理解しつつ、実際のプロダクトのコードで使っていくようにした方がよかった。</p>
<h3>来年やること</h3>
<h4>フロントとインフラ</h4>
<p>あれこれ他の言語に手を出さず、自分で意図的に <a class="keyword" href="http://d.hatena.ne.jp/keyword/Rails">Rails</a> だけやってきたのでここは強みだと思う反面、他の言語とかフロント、インフラ周りになるとなかなかアウトプット出せないなって感じた...</p>
<p>フロントと最低限のインフラ知識は必要だなと思うので、この辺りは自プロダクトも含めて埋めていきたい。</p>
<h4><a class="keyword" href="http://d.hatena.ne.jp/keyword/Ruby">Ruby</a> と <a class="keyword" href="http://d.hatena.ne.jp/keyword/Rails">Rails</a></h4>
<p>そして、 <a class="keyword" href="http://d.hatena.ne.jp/keyword/Rails">Rails</a> 周りのインプットを増やせば増やすほど、こんな書き方できるのか!こうやって model を分けるのか!とか新しい発見が多くて、もっと知っていい感じのコード書けるようになりたいと思った。</p>
<p>なので、本やサイトから <a class="keyword" href="http://d.hatena.ne.jp/keyword/Ruby">Ruby</a> や <a class="keyword" href="http://d.hatena.ne.jp/keyword/Rails">Rails</a> 周りのインプット・アウトプットは今後も続けつつ、<a class="keyword" href="http://d.hatena.ne.jp/keyword/OSS">OSS</a>のコードを読んでいろんな書き方を学びつつ、<a class="keyword" href="http://d.hatena.ne.jp/keyword/OSS">OSS</a>貢献もやっていきたい。</p>
<p>また、人が多いところが苦手で勉強会とかにあまり参加していなかったので、来年は参加する機会を増やしていこうと思う。</p>
<h4>ブログ</h4>
<p>今年は全く書いてなかった。</p>
<p>こんなこと書いてもな〜...って思うこともあったけど、今でも昔の記事読むと、しょーもな!って思うことで悩んだりしてたみたいなので、作業ログ的に記録を残しておくと、「この当時はこんなことで悩んどったんだな」とかあとあと振り返りがしやすいかなと思う。</p>
<p>自分の記録を残すって意味でも、もう少し何かしら書いていこうと思う。</p>
<h4>自プロダクト</h4>
<p>自分のプロダクトとして <a href="https://growth-support.net">Growth Support</a> を作った。いいプロダクトになると思っているので開発を進めてさらにいいものにしていきたい。</p>
<p>また、くだらないサービスもどんどん作って公開していきたいと思う。その過程で知識不足なフロントとインフラを埋めていければいいと思っている。</p>
<h3>まとめ</h3>
<p>そんなこんなで、今年はとても楽しい一年だった。</p>
<p>やることもたくさんあるし、知りたいこともいっぱいある。まだまだ<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%D7%A5%ED%A5%B0%A5%E9%A5%DE%A1%BC">プログラマー</a>として楽しい日々が送れそうなので、来年はもっと楽しい一年にしたいと思う。</p> Sat, 30 Dec 2017 14:24:55 +0900
hatenablog://entry/8599973812331399582
個人的なこと
-
webpack2 : チュートリアルをやってみた!
https://31webcreation.hatenablog.com/entry/webpack2-tutorial <p>最近よく聞く webpack !</p>
<p>いろんなプロジェクトで使われてて裏でいい感じに動いていて勉強しないとと思って数ヶ月...やりました!</p>
<p>バージョンが 2 になってたみたいで、<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C1%A5%E5%A1%BC%A5%C8%A5%EA%A5%A2%A5%EB">チュートリアル</a>やったら動かなくて困った...</p>
<p>とりあえず以下を参考に動くところまでは持っていった!</p>
<p> </p>
<p><iframe class="embed-card embed-webcard" style="display: block; width: 100%; height: 155px; max-width: 500px; margin: 10px 0px;" title="Getting Started" src="//hatenablog-parts.com/embed?url=https%3A%2F%2Fwebpack.js.org%2Fguides%2Fget-started%2F" frameborder="0" scrolling="no"></iframe><cite class="hatena-citation"><a href="https://webpack.js.org/guides/get-started/">webpack.js.org</a></cite></p>
<p>で、初心者なのでここからどうしよう...と思って見つけたのがこの<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C1%A5%E5%A1%BC%A5%C8%A5%EA%A5%A2%A5%EB">チュートリアル</a>!なのでこれをやってみました!</p>
<p><a href="https://blog.madewithenvy.com/getting-started-with-webpack-2-ed2b86c68783">Getting Started with webpack 2 – Thinking in Code</a></p>
<p>今の状態としては、webpack の Getting Started をやって終わっている状態です!</p>
<p>- webpackのバージョンは 2.3.2</p>
<h3>yarnを使う</h3>
<p>これも聞いたことがある!パッケージマネージャらしい!</p>
<blockquote>
<p>Yarn is a package manager for your code.</p>
</blockquote>
<p><iframe class="embed-card embed-webcard" style="display: block; width: 100%; height: 155px; max-width: 500px; margin: 10px 0px;" title="Yarn" src="//hatenablog-parts.com/embed?url=https%3A%2F%2Fyarnpkg.com%2Fen%2F" frameborder="0" scrolling="no"></iframe><cite class="hatena-citation"><a href="https://yarnpkg.com/en/">yarnpkg.com</a></cite></p>
<p>以下を実行すると yarn が使えるようになるっぽい。</p>
<pre id="d08b" class="graf graf--pre graf-after--p" style="overflow: auto; font-family: Menlo, Monaco, 'Courier New', Courier, monospace; font-size: 16px; margin: 43px 0px 0px; background: rgba(0, 0, 0, 0.0470588); padding: 20px; white-space: pre-wrap; color: rgba(0, 0, 0, 0.8); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a class="keyword" href="http://d.hatena.ne.jp/keyword/brew">brew</a> install yarn<br />yarn add --dev webpack webpack-dev-server@2</pre>
<p> </p>
<p>基本的には記事通りにやって行けば大丈夫だと思うけど、動かなかったところをメモしていく!</p>
<h3>webpack-dev-server</h3>
<p>これも当たり前なんかな?普通にターミナルに入力して動かなくて、以下のコマンドでインス<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C8%A1%BC%A5%EB">トール</a>後に動いた。</p>
<pre id="d08b" class="graf graf--pre graf-after--p" style="overflow: auto; font-family: Menlo, Monaco, 'Courier New', Courier, monospace; font-size: 16px; margin: 43px 0px 0px; background: rgba(0, 0, 0, 0.0470588); padding: 20px; white-space: pre-wrap; color: rgba(0, 0, 0, 0.8); font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">npm install -g webpack-dev-server</pre>
<p> </p>
<h3>extract-text-webpack-plugin</h3>
<p>記事内では beta 版が使われているようだったけど、今は大丈夫っぽい!</p>
<pre style="box-sizing: border-box; font-family: SFMono-Regular, Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; margin-top: 0px; margin-bottom: 0px; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; background-color: #f6f8fa; border-radius: 3px; word-break: normal; color: #24292e; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">npm install --save-dev extract-text-webpack-plugin</pre>
<p><iframe class="embed-card embed-webcard" style="display: block; width: 100%; height: 155px; max-width: 500px; margin: 10px 0px;" title="webpack-contrib/extract-text-webpack-plugin" src="//hatenablog-parts.com/embed?url=https%3A%2F%2Fgithub.com%2Fwebpack-contrib%2Fextract-text-webpack-plugin" frameborder="0" scrolling="no"></iframe><cite class="hatena-citation"><a href="https://github.com/webpack-contrib/extract-text-webpack-plugin">github.com</a></cite></p>
<h3>まとめ</h3>
<p>とりあえず動くようになったけど、実際にコード書いていかないと分からないな(笑)</p>
<p>これからいじっていく予定!</p> Sun, 02 Apr 2017 13:50:30 +0900
hatenablog://entry/10328749687233570055
webpack2
webpack
yarn
-
【Rails5】devise でログイン後ページをユーザー意図に合わせて変更する
https://31webcreation.hatenablog.com/entry/set-page-after-login-with-session <p>前回の記事でログイン後ページのリダイレクトを設定しました。</p>
<p>ログアウトした状態でログイン後の特定ページにいった場合、ログインページに遷移し、ログインするとその設定したページにリダイレクトされます。</p>
<p>しかし、その場合ユーザーとしてはログインするとそのログイン後の特定ページにリダイレクトされたいと思います。</p>
<p>今回はその機能を実装していきます。</p>
<h3>ログイン前のページを保存する</h3>
<p>以下のページで解説がありますので、そのとおりに実装していきます。</p>
<p><a href="https://github.com/plataformatec/devise/wiki/How-To:-Redirect-back-to-current-page-after-sign-in,-sign-out,-sign-up,-update">How To: Redirect back to current page after sign in, sign out, sign up, update · plataformatec/devise Wiki · GitHub</a></p>
<p>まず app/controllers/application_controller.rb に以下を追記します。</p>
<pre>class ApplicationController < <a class="keyword" href="http://d.hatena.ne.jp/keyword/ActionController">ActionController</a>::Base<br /> before_action :store_current_location, unless: :devise_controller?<br /> before_action :authenticate_user!<br /><br /> ...<br /><br /> private<br /><br /> def store_current_location<br /> store_location_for(:user, request.url)<br /> end<br />end</pre>
<p>これでログイン前のページが保存されます。</p>
<h3>ログイン後のリダイレクトを修正</h3>
<p>次に以下のようにしてログイン後のリダイレクトを先ほどの保存したログイン前ページを使うように修正します。</p>
<pre> def after_sign_in_path_for(resource)<br /> stored_location_for(resource) || mypage_root_path<br /> end</pre>
<h3>ログイン不要ページを除く</h3>
<p>この設定でほぼOKなんですが、ログインが不要なページからログインページに遷移した場合もこの機能が働きます。</p>
<p>例えば、トップからログインページに遷移した場合、ログイン後はトップに戻ります。しかし、ここではログイン後のトップ(上記例では mypage_root_path)に遷移させたいと思います。</p>
<p>なので、その設定を行います。なお、ここではログイン不要のページ(トップページ)を home_controller で設定しているとします。</p>
<pre>class ApplicationController < <a class="keyword" href="http://d.hatena.ne.jp/keyword/ActionController">ActionController</a>::Base<br /> before_action :store_current_location, unless: :devise_or_home_controller?<br /> before_action :authenticate_user!<br /><br /> ...<br /><br /> private<br /><br /> ...<br /><br /> def devise_or_home_controller?<br /> devise_controller? || controller_name == 'home'<br /> end<br />end</pre>
<p>これで home_controller は保存されなくなり、意図通り mypage_root_path に遷移します。 controller_name == 'home' の部分はもう少しやりようがある気がしてますが、ひとまず、これで動きます。</p>
<p>それ以外でいい方法があれば教えてください!</p>
<p>ということで今回はここまで。</p>
<p> </p>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">devise 関連記事はこちら</p>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/2016/07/31/083000">【Rails5】devise でログイン機能を実装する</a></p>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/translate-devise-to-japanese">【Rails5】devise を日本語化する</a></p>
<p><a href="http://31webcreation.hatenablog.com/entry/set-page-after-login-and-logout">【Rails5】devise でログイン後、ログアウト後のページを設定する</a></p> Fri, 13 Jan 2017 07:00:00 +0900
hatenablog://entry/10328749687204945903
Rails
-
【Rails5】gem omniauth-google-oauth2 のrspecテストではまった
https://31webcreation.hatenablog.com/entry/omniauth-google-oauth2-rspec <p>ログインテストを書いていてハマったのでメモ。</p>
<p>以下を参考にテストを書いていた。</p>
<p><a href="https://github.com/omniauth/omniauth/wiki/Integration-Testing">Integration Testing · omniauth/omniauth Wiki · GitHub</a></p>
<p><a href="http://easyramble.com/request-spec-for-devise-omniatuh.html">Rails + Devise + OmniAuth で Facebook/Twitter の OAuth 認証を RSpec + Capybara でインテグレーションテスト(RequestSpec) | EasyRamble</a></p>
<p><a href="http://www.jessespevack.com/blog/2016/10/16/how-to-test-drive-omniauth-google-oauth2-for-your-rails-app">How to Test Drive OmniAuth Google OAuth2 for your Rails App — Jesse Spevack</a></p>
<p> </p>
<p>なるほど!なるほど!と思いながら真似してやっていたが、上手く行かず...</p>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/rspec">rspec</a> 内に binding.pry を仕込んで中を見てみると上手く設定できてないみたいで、デフォルトのパラメータが返ってくる。</p>
<pre>[3] pry(#<Users::OmniauthCallbacksController>)> request.env['omniauth.auth']<br />=> {"provider"=>"default",<br /> "uid"=>"1234",<br /> "info"=>{"name"=>"Example User"}}</pre>
<h3>omniauth-<a class="keyword" href="http://d.hatena.ne.jp/keyword/google">google</a>-oauth2 を使っている場合は <a class="keyword" href="http://d.hatena.ne.jp/keyword/google">google</a>_oauth2</h3>
<p>原因は mock を作るときに以下のように <a class="keyword" href="http://d.hatena.ne.jp/keyword/google">google</a> を設定していたこと。</p>
<pre>OmniAuth.config.mock_auth[:<a class="keyword" href="http://d.hatena.ne.jp/keyword/google">google</a>]</pre>
<p>これを <a class="keyword" href="http://d.hatena.ne.jp/keyword/google">google</a>_oauth2 に修正したら上手くいきました!</p>
<pre>OmniAuth.config.mock_auth[:<a class="keyword" href="http://d.hatena.ne.jp/keyword/google">google</a>_oauth2]</pre>
<p>mock を使ったテスト自体ほとんど書いたことがなかったので、これを解決するのにハマってしまった...</p> Thu, 12 Jan 2017 19:00:00 +0900
hatenablog://entry/10328749687205919393
-
【Rails5】devise でログイン後、ログアウト後のページを設定する
https://31webcreation.hatenablog.com/entry/set-page-after-login-and-logout <p>ユーザーがログインした後、ログアウトした後のページへの遷移をデフォルトのものから変更したいと思います。</p>
<p>以下のページの項目を読むと after_sign_in_path_for と after_sign_out_path_for をオーバーライドしてねってあるので、その通りやっていきます。</p>
<p><a href="https://github.com/plataformatec/devise#controller-filters-and-helpers">GitHub - plataformatec/devise: Flexible authentication solution for Rails with Warden.</a></p>
<h3>application_controller.rb に追記</h3>
<p>以下のように <span style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float: none;">after_sign_in_path_for にログイン後のページ、 <span style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff; display: inline !important; float: none;">after_sign_out_path_for にログアウト後のページを設定するとリダイレクトしてくれます。</span></span></p>
<pre><code>class ApplicationController < ActionController::Base<br /> before_action :authenticate_user!<br /><br /> def after_sign_in_path_for(resource)<br /> mypage_root_path # ログイン後に遷移するpathを設定<br /> end<br /><br /> def after_sign_out_path_for(resource)<br /> new_user_session_path # ログアウト後に遷移するpathを設定<br /> end<br />end</code></pre>
<p>思ったよりサクッといけました!</p>
<p> </p>
<p>devise 関連記事はこちら</p>
<p><a href="http://31webcreation.hatenablog.com/entry/2016/07/31/083000">【Rails5】devise でログイン機能を実装する</a></p>
<p><a href="http://31webcreation.hatenablog.com/entry/translate-devise-to-japanese">【Rails5】devise を日本語化する</a></p>
<p><a href="http://31webcreation.hatenablog.com/entry/set-page-after-login-with-session">【Rails5】devise でログイン後ページをユーザー意図に合わせて変更する</a></p> Tue, 10 Jan 2017 07:00:00 +0900
hatenablog://entry/10328749687204925167
Rails
-
【Rails5】devise を日本語化する
https://31webcreation.hatenablog.com/entry/translate-devise-to-japanese <p>前回はログイン機能の実装を行いましたが、今回はこれを日本語化していきたいと思います。</p>
<p><iframe class="embed-card embed-blogcard" style="display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;" title="【Rails5】devise でログイン機能を実装する - グロースエンジニアのブログ" src="http://31webcreation.hatenablog.com/embed/2016/07/31/083000" frameborder="0" scrolling="no"></iframe></p>
<h3><cite class="hatena-citation">デフォルトの<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%ED%A5%B1%A1%BC%A5%EB">ロケール</a>を設定する</cite></h3>
<p>deviseのページに方法が書いてあるので、これどおりにやっていきます。</p>
<p><a href="https://github.com/plataformatec/devise/wiki/I18n">I18n · plataformatec/devise Wiki · GitHub</a></p>
<p>config/application.rb にデフォルトの<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%ED%A5%B1%A1%BC%A5%EB">ロケール</a>を設定します。</p>
<pre><code>config.i18n.default_locale = :ja<br /></code></pre>
<p>デフォルトで何か設定されている場合は修正してください。</p>
<h3> 日本語化ファイルを設定する</h3>
<p>config/locales/devise.ja.yml というファイルを作成し、上記ページにある日本語翻訳ファイルをコピペします。 </p>
<pre><code># Additional translations at https://github.com/plataformatec/devise/wiki/I18n
ja:
devise:
confirmations:
confirmed: 'アカウントを登録しました。'
send_instructions: 'アカウントの有効化について数分以内にメールでご連絡します。'
send_paranoid_instructions: "あなたのメールアドレスが登録済みの場合、本人確認用のメールが数分以内に送信されます。"
failure:
already_authenticated: 'すでにログインしています。'
inactive: 'アカウントが有効化されていません。メールに記載された手順にしたがって、アカウントを有効化してください。'
invalid: "%{authentication_keys} もしくはパスワードが不正です。"
locked: 'あなたのアカウントは凍結されています。'
last_attempt: 'あなたのアカウントが凍結される前に、複数回の操作がおこなわれています。'
not_found_in_database: "%{authentication_keys} もしくはパスワードが不正です。"
timeout: 'セッションがタイムアウトしました。もう一度ログインしてください。'
unauthenticated: 'アカウント登録もしくはログインしてください。'
unconfirmed: 'メールアドレスの本人確認が必要です。'
mailer:
confirmation_instructions:
subject: 'アカウントの有効化について'
reset_password_instructions:
subject: 'パスワードの再設定について'
unlock_instructions:
subject: 'アカウントの凍結解除について'
password_change:
subject: 'パスワードの変更について'
omniauth_callbacks:
failure: "%{kind} アカウントによる認証に失敗しました。理由:(%{reason})"
success: "%{kind} アカウントによる認証に成功しました。"
passwords:
no_token: "このページにはアクセスできません。パスワード再設定メールのリンクからアクセスされた場合には、URL をご確認ください。"
send_instructions: 'パスワードの再設定について数分以内にメールでご連絡いたします。'
send_paranoid_instructions: "あなたのメールアドレスが登録済みの場合、パスワード再設定用のメールが数分以内に送信されます。"
updated: 'パスワードが正しく変更されました。'
updated_not_active: 'パスワードが正しく変更されました。'
registrations:
destroyed: 'アカウントを削除しました。またのご利用をお待ちしております。'
signed_up: 'アカウント登録が完了しました。'
signed_up_but_inactive: 'ログインするためには、アカウントを有効化してください。'
signed_up_but_locked: 'アカウントが凍結されているためログインできません。'
signed_up_but_unconfirmed: '本人確認用のメールを送信しました。メール内のリンクからアカウントを有効化させてください。'
update_needs_confirmation: 'アカウント情報を変更しました。変更されたメールアドレスの本人確認のため、本人確認用メールより確認処理をおこなってください。'
updated: 'アカウント情報を変更しました。'
sessions:
signed_in: 'ログインしました。'
signed_out: 'ログアウトしました。'
already_signed_out: '既にログアウト済みです。'
unlocks:
send_instructions: 'アカウントの凍結解除方法を数分以内にメールでご連絡します。'
send_paranoid_instructions: 'アカウントが見つかった場合、アカウントの凍結解除方法を数分以内にメールでご連絡します。'
unlocked: 'アカウントを凍結解除しました。'
errors:
messages:
already_confirmed: 'は既に登録済みです。ログインしてください。'
confirmation_period_expired: "の期限が切れました。%{period} までに確認する必要があります。 新しくリクエストしてください。"
expired: 'の有効期限が切れました。新しくリクエストしてください。'
not_found: 'は見つかりませんでした。'
not_locked: 'は凍結されていません。'
not_saved:
one: "エラーが発生したため %{resource} は保存されませんでした:"
other: "%{count} 件のエラーが発生したため %{resource} は保存されませんでした:"</code></pre>
<p>これで devise に関連する表示は日本語化できました。</p>
<h3>モデルも日本語化する</h3>
<p>ついでと言っては何ですが、フォームなどに表示される項目も日本語化していきたいと思います。</p>
<p>Email や Password といった表示はモデルの属性によるものなので、 config/locales/models.ja.yml などのファイルを作成し、以下を追記します。</p>
<pre><code>ja:
activerecord:
attributes:
user:
email: メールアドレス
password: パスワード
password_confirmation: 確認用パスワード<br /> remember_me: 次回から自動的にログイン<br /></code></pre>
<p>これでフォームに表示される項目も日本語化できます。</p>
<h3>それ以外の日本語化</h3>
<p>それ以外の箇所は直接viewにかかれているようなので、それを修正すればいいかと。必要に応じて <a class="keyword" href="http://d.hatena.ne.jp/keyword/I18n">I18n</a> 化する感じです。</p>
<p>例えば app/views/devise/sessions/new.html.erb がログインフォームなので、このファイルを開いて日本語に書き換えます。</p>
<pre><code><h2>ログイン</h2><br /><%= form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %><br /> <div class="field"><br /> <%= f.label :email %><br /><br /> <%= f.email_field :email, autofocus: true %><br /> </div><br /><br /> <div class="field"><br /> <%= f.label :password %><br /><br /> <%= f.password_field :password, autocomplete: "off" %><br /> </div><br /><br /> <% if devise_mapping.rememberable? -%><br /> <div class="field"><br /> <%= f.check_box :remember_me %><br /> <%= f.label :remember_me %><br /> </div><br /> <% end -%><br /><br /> <div class="actions"><br /> <%= f.submit "ログイン" %><br /> </div><br /><% end %><br /><br /><%= render "devise/shared/links" %><br /></code></pre>
<p> 一番最後にある devise/shared/links はフォームの最下部にあるリンクを作成している viewなので、これも必要に合わせて修正してください。</p>
<p> </p>
<p>以上、 devise の日本語化でした!</p>
<p> </p>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">devise 関連記事はこちら</p>
<p><a href="http://31webcreation.hatenablog.com/entry/2016/07/31/083000">【Rails5】devise でログイン機能を実装する</a></p>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/set-page-after-login-and-logout">【Rails5】devise でログイン後、ログアウト後のページを設定する</a></p>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/set-page-after-login-with-session">【Rails5】devise でログイン後ページをユーザー意図に合わせて変更する</a></p>
<p> </p> Mon, 09 Jan 2017 11:00:00 +0900
hatenablog://entry/10328749687204903629
Rails
-
Rails アプリを複数(2つ以上)立ち上げる方法
https://31webcreation.hatenablog.com/entry/multi-rails-apps <p>最近マイクロサービスというものを調べる機会があって、記事などを読んでいた。</p>
<p>で、気になったのが「ローカルでどうやって開発するの?」でした。</p>
<p>開発者なら当たり前なのかもしれませんが、こういう機会があって初めて課題に気づき調べて分かることだったのでメモしておきます。</p>
<h3>ポートを指定して <a class="keyword" href="http://d.hatena.ne.jp/keyword/rails">rails</a> s!</h3>
<p>そんなことできたんだな...</p>
<p>通常の `<a class="keyword" href="http://d.hatena.ne.jp/keyword/rails">rails</a> s` だと 3000 でアプリが立ち上がる。</p>
<p>複数立ち上げたいときは `<a class="keyword" href="http://d.hatena.ne.jp/keyword/rails">rails</a> s -p 4000` とか、`-p ポート番号` って指定してあげればOK!</p>
<p>たとえば上記で <a class="keyword" href="http://d.hatena.ne.jp/keyword/rails">rails</a> アプリを立ち上げて、 <a href="http://localhost:4000/">http://localhost:4000/</a> にアクセスすれば起動してる。</p>
<p>なるほどな〜とwww</p>
<h3>今後の開発</h3>
<p>せっかくの機会なので、マイクロサービス周りを調べつつ、テスト的に何か作れればと思っている。</p>
<p>まだまだどういうときに必要で、どういった技術的なものや知識が必要になるのか分かっていないので徐々にやっていくつもりです!</p> Sat, 15 Oct 2016 11:05:47 +0900
hatenablog://entry/10328749687189493637
Rails
-
【Rails5】devise でログイン機能を実装する
https://31webcreation.hatenablog.com/entry/2016/07/31/083000 <p>devise を使ってログイン機能を実装してきます。</p>
<p>2016年7月30日時点で Rails5 対応しているのかちょっとわからなかったのですが、実装できたのでメモしておきます。</p>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">その他、devise 関連記事を書いているので参考にどうぞ。</p>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/translate-devise-to-japanese">【Rails5】devise を日本語化する</a></p>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/set-page-after-login-and-logout">【Rails5】devise でログイン後、ログアウト後のページを設定する</a></p>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/set-page-after-login-with-session">【Rails5】devise でログイン後ページをユーザー意図に合わせて変更する</a></p>
<h3>devise をインストール</h3>
<p>Gemfile に以下を追加して、ターミナルから bundle install を実行します。</p>
<pre><code>gem 'devise'</code></pre>
<p>次にターミナルから <a class="keyword" href="http://d.hatena.ne.jp/keyword/rails">rails</a> generate devise:install を実行するとインストール手順が表示されます。</p>
<pre><code>➜ app git:(master) rails generate devise:install
Running via Spring preloader in process 33841
create config/initializers/devise.rb
create config/locales/devise.en.yml
===============================================================================
Some setup you must do manually if you haven't yet:
1. Ensure you have defined default url options in your environments files. Here
is an example of default_url_options appropriate for a development environment
in config/environments/development.rb:
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
In production, :host should be set to the actual host of your application.
2. Ensure you have defined root_url to *something* in your config/routes.rb.
For example:
root to: "home#index"
3. Ensure you have flash messages in app/views/layouts/application.html.erb.
For example:
<%= notice %>
<%= alert %>
4. You can copy Devise views (for customization) to your app by running:
rails g devise:views
===========================================================
</code></pre>
<p>この手順通りにやっていきます。</p>
<h4>1. 開発環境でのメール設定</h4>
<p>config/environments/development.rb ファイル内に以下を追記します。</p>
<pre><code>config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }</code></pre>
<h4>2. route を追加</h4>
<p>config/routes.rb に root to: 'home#index' を追加します。</p>
<h4>3. ログイン関連の <a class="keyword" href="http://d.hatena.ne.jp/keyword/flash">flash</a> メッセージの表示</h4>
<p>app/views/layouts/application.html.erb に <a class="keyword" href="http://d.hatena.ne.jp/keyword/flash">flash</a> メッセージ用のタグを追加</p>
<pre><code><%= notice %>
<%= alert %></code></pre>
<h4>4. ログイン関係の view を作成</h4>
<p>ターミナルから以下を実行することでログイン関連のviewのベースを作成します。</p>
<pre><code>➜ app git:(master) rails g devise:views
Running via Spring preloader in process 34244
invoke Devise::Generators::SharedViewsGenerator
create app/views/devise/shared
create app/views/devise/shared/_links.html.erb
invoke form_for
create app/views/devise/confirmations
create app/views/devise/confirmations/new.html.erb
create app/views/devise/passwords
create app/views/devise/passwords/edit.html.erb
create app/views/devise/passwords/new.html.erb
create app/views/devise/registrations
create app/views/devise/registrations/edit.html.erb
create app/views/devise/registrations/new.html.erb
create app/views/devise/sessions
create app/views/devise/sessions/new.html.erb
create app/views/devise/unlocks
create app/views/devise/unlocks/new.html.erb
invoke erb
create app/views/devise/mailer
create app/views/devise/mailer/confirmation_instructions.html.erb
create app/views/devise/mailer/password_change.html.erb
create app/views/devise/mailer/reset_password_instructions.html.erb
create app/views/devise/mailer/unlock_instructions.html.erb</code></pre>
<h3>ログインユーザー用のUserモデルの作成</h3>
<p>ターミナルから <a class="keyword" href="http://d.hatena.ne.jp/keyword/rails">rails</a> g devise User を実行し、ログインしたユーザーを登録するモデルを作成します。</p>
<h3>ログイン後のページを作る</h3>
<p>テスト用に以下のようなログイン後のページを作成します。</p>
<pre><code># app/controllers/mypages_controller.rb
class MypagesController < ApplicationController
before_action :authenticate_user!
def show
end
end
# app/views/mypages/show.html.erb
mypage#show
# config/routes.rb
Rails.application.routes.draw do
devise_for :users
root to: 'home#index'
resource :mypage
end</code></pre>
<p>サーバーを再起動し、<a href="http://localhost:3000/mypage">http://localhost:3000/mypage</a> にアクセスするとログインページが表示されると思います。</p>
<p>これは、 before_action :authenticate_user! がログインしているかをチェックしており、していなければログインページにリダイレクトされます。</p>
<h3>ログイン、ログアウトのリンクを追加する</h3>
<p>ログインしていない状態で、ログインが必要なページに直接アクセスするとログインフォームにリダイレクトされます。</p>
<p>ただ、ログインフォームへのリンクとログアウトするリンクが必要となります。</p>
<p>そのためのリンクが以下です。</p>
<pre><code><% if user_signed_in? %>
<%= link_to('Logout', destroy_user_session_path, :method => :delete) %>
<% else %>
<%= link_to('Login', new_user_session_path) %>
<% end %></code></pre>
<p>これをリンクを追加したい場所に追加すれば大丈夫です。</p>
<p>以上、devise の実装でした。</p>
<p>次は devise を日本語化していきたいと思います。</p>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;">その他、devise 関連記事はこちら</p>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/translate-devise-to-japanese">【Rails5】devise を日本語化する</a></p>
<p><a href="http://31webcreation.hatenablog.com/entry/set-page-after-login-and-logout">【Rails5】devise でログイン後、ログアウト後のページを設定する</a></p>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant-ligatures: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: 2; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/set-page-after-login-with-session">【Rails5】devise でログイン後ページをユーザー意図に合わせて変更する</a></p> Sun, 31 Jul 2016 08:30:00 +0900
hatenablog://entry/10328749687176759556
Rails
-
Ruby on Rails 5 で新しくアプリを作成する
https://31webcreation.hatenablog.com/entry/rails5_new <p>新しく作りたいものを思い立って、せっかくなので <a class="keyword" href="http://d.hatena.ne.jp/keyword/Rails">Rails</a> 5 で作ろうと思ったので、その手順を簡単に。</p>
<p>今の自分のローカル環境としては、<a class="keyword" href="http://d.hatena.ne.jp/keyword/Rails">Rails</a> 4 は動く状態です。</p>
<h3><a class="keyword" href="http://d.hatena.ne.jp/keyword/Rails">Rails</a> 5 のインストール</h3>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%EA%A5%DD%A5%B8%A5%C8%A5%EA">リポジトリ</a>はこちら。手順も READ ME に書いてあるので、そちらを見た方が早いかもしれません。</p>
<p><iframe class="embed-card embed-webcard" style="display: block; width: 100%; height: 155px; max-width: 500px; margin: 10px 0px;" title="rails/rails" src="//hatenablog-parts.com/embed?url=https%3A%2F%2Fgithub.com%2Frails%2Frails" frameborder="0" scrolling="no"></iframe></p>
<p>ターミナルから以下を実行。</p>
<pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; margin-top: 0px; margin-bottom: 16px; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; border-radius: 3px; color: #333333; letter-spacing: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #f7f7f7;"><code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0px; margin: 0px; border-radius: 3px; word-break: normal; white-space: pre; border: 0px; display: inline; overflow: visible; line-height: inherit; word-wrap: normal; background: transparent;">gem install rails</code></pre>
<p>実行結果を見ていくと <a class="keyword" href="http://d.hatena.ne.jp/keyword/rails">rails</a> 5 が入ってますね!(長いので省略してます)</p>
<pre><code>Fetching: activesupport-5.0.0.gem (100%)
Successfully installed activesupport-5.0.0
Fetching: rack-2.0.1.gem (100%)
Successfully installed rack-2.0.1
...
Parsing documentation for rails-5.0.0
Installing ri documentation for rails-5.0.0
Done installing documentation for activesupport, rack, rails-dom-testing, actionview, actionpack, activemodel, arel, activerecord, activejob, actionmailer, actioncable, railties, rails after 24 seconds
13 gems installed</code></pre>
<h3>アプリの起動</h3>
<p>ここから先はいつもどおりです。<br />※ myapp のところは作るアプリ名に修正</p>
<pre style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; margin-top: 0px; margin-bottom: 16px; font-style: normal; font-variant: normal; font-weight: normal; font-stretch: normal; line-height: 1.45; word-wrap: normal; padding: 16px; overflow: auto; border-radius: 3px; color: #333333; letter-spacing: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #f7f7f7;"><code style="box-sizing: border-box; font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; font-size: 13.6px; padding: 0px; margin: 0px; border-radius: 3px; word-break: normal; white-space: pre; border: 0px; display: inline; overflow: visible; line-height: inherit; word-wrap: normal; background: transparent;">rails new myapp<br /></code>cd myapp<br /><a class="keyword" href="http://d.hatena.ne.jp/keyword/rails">rails</a> server</pre>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160730140845p:plain" src="https://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160730/20160730140845.png" alt="f:id:ikdtty0423:20160730140845p:plain" /></p>
<p>もうちょっとゴニョゴニョやる必要があるかなと思ったけど簡単だった。</p>
<p>これで <a class="keyword" href="http://d.hatena.ne.jp/keyword/Rails">Rails</a> 5 で開発ができる!</p> Sat, 30 Jul 2016 14:07:13 +0900
hatenablog://entry/10328749687176715756
Rails
-
超集中を手に入れる5つのテクニック 〜自分を操る超集中力 メンタリスト DaiGo〜
https://31webcreation.hatenablog.com/entry/tyou-syuutyuu-daigo <p>前から気になっていたメンタリストDaiGo。</p>
<p>人の振る舞いからその人の心理を当てるパフォーマンスをテレビで見て、この人どうやって見抜いてるんだろう?って興味があった。</p>
<p>たまたま本屋にいったらDaiGoの本が複数並んでいて、こんなに本書いてんの?と思いつつ、いい機会なので読んでみようと思った。今回は「自分を操る超集中力」って本の感想を。</p>
<h3>集中は作り出せる</h3>
<p>集中しているときってそのことに没頭していて、気が付くと1時間、2時間ってあっという間に時間が経つ。</p>
<p>でも、結構気が散って集中できないことも多々ある。</p>
<p>自分のパフォーマンスを上げるにはどうやって集中を作りだすかが鍵になってくる。</p>
<p>そんな方法を脳の研究も合わせて紹介しているのがこの本。</p>
<p><iframe style="width: 120px; height: 240px;" src="http://rcm-fe.amazon-adsystem.com/e/cm?lt1=_top&bc1=FFFFFF&IS2=1&nou=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=tatsuyanoheya-22&o=9&p=8&l=as1&m=amazon&f=ifr&ref=tf_til&asins=4761271760" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<h3>超集中する5つのテクニック</h3>
<p>集中するテクニックがたくさん紹介されているので、細かいテクニックは本を読んでもらいたいのですが、僕が大事に思ったことを一言で言うと、「集中できる環境づくり」。</p>
<p>それをピックアップして紹介します。</p>
<h4>机には青いもの、青色のペンを使う</h4>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/%BF%A7%BA%CC%BF%B4%CD%FD%B3%D8">色彩心理学</a>で青は集中を促す色。これ、結構前からやっているけど、何となくしっくりきていると思う。</p>
<p>机の上に青いものを置いたり、青色のペンを使うだけなので簡単にできると思う。</p>
<h4>気が散るものを排除する</h4>
<p>例えば<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%B9%A5%DE%A5%DB">スマホ</a>。集中しててもブルっと震えれば気になってしまう。その時点で集中は切れる。</p>
<p>集中したいときはマナーモード...というか、<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%D0%A5%A4">バイ</a>ブレーションも止めてしまうのがいいと思う。かばんに入れていてもブルブルすると音が出て気になることもあるので。</p>
<p>それ以外にも電話が鳴らない早い時間に行って仕事するなど邪魔が入らない環境で仕事することが大事。</p>
<h4>やることを6つ書き出して優先順位付け</h4>
<p>その日にやる6つのことを書き出して優先順位付けし、上から順にやっていく方法。</p>
<p>紙に書き出すことに意味があって、頭に覚えているということは脳を使っているということ。</p>
<p>自分の頭のなかにあるタスクを紙に書きだして脳をクリアにする。それによって目の前のコトの集中できる状態を作れるというわけです。</p>
<h4>やることを一つに絞る</h4>
<p>僕もよくあるんですが、あれもやらないと、これもやらないとって思って結局ほとんど終わらないという...</p>
<p>先ほどの紙に書き出して優先順位付けしたものを1つずつやっていくことで、それだけに集中して仕事ができる。</p>
<p>複数平行してやるとアイドリング(その仕事をする準備)に時間がかかるので一つのことに集中してやることが大事。</p>
<h4>25分仕事、5分休憩</h4>
<p>何となく聞いたことがある方もいるかもしれませんが、ポモドーロというやつです。</p>
<p>人の集中できる時間は限られているので適度に休憩を入れて集中を維持することが大事。</p>
<p>僕もやろうと思いつつ、そんな細かく区切ってたらアイドリングに時間かかるし無駄だと思う...って思ってやってなかった。</p>
<p>でも、一つのことに絞ってやるのであれば休憩中も脳はその仕事を考えており問題ないとのこと。</p>
<p>その休憩中にナッツなどの<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C4%E3GI%BF%A9%C9%CA">低GI食品</a>で血糖値をコン<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C8%A5%ED%A1%BC%A5%EB">トロール</a>しつつ、1,2時間にコップ1杯の水を飲む。</p>
<p>脳は<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%D6%A5%C9%A5%A6%C5%FC">ブドウ糖</a>をエネルギーとしていて、ナッツによって補給しつつ、水分不足による集中力低下を防ぐことができます。</p>
<h3>超集中を手に入れる</h3>
<p>明日、大事なプレゼンなのに...とか午後までに資料まとめないと...とか集中して一気にやらない場面はたくさんあると思います。</p>
<p>そういうときに限って中々手を付けられなかったりすることもあると思います。</p>
<p>簡単なことから少しずつ始めて集中力を手に入れてみてはいかがでしょうか?</p>
<p><iframe style="width: 120px; height: 240px;" src="http://rcm-fe.amazon-adsystem.com/e/cm?lt1=_top&bc1=FFFFFF&IS2=1&nou=1&bg1=FFFFFF&fc1=000000&lc1=0000FF&t=tatsuyanoheya-22&o=9&p=8&l=as1&m=amazon&f=ifr&ref=tf_til&asins=4761271760" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p>【目次】</p>
<p>まえがき<br /> 第1章 集中力を自在に操る3つのルール<br /> 集中力の高い人に共通する行動原則とは<br />第2章 高い集中力を生み出す7つのエンジン<br /> トップスピードで「すぐ没頭できる」自分に変わる<br />第3章 疲れをリセットする3つの回復法<br /> 疲れを感じている方は、ここから読み進めてください<br /> 第4章 集中力を自動でつくり出す時間術<br /> いつもの仕事の時間を変えるだけで、パフォーマンスは上がっていく</p> Mon, 11 Jul 2016 06:30:00 +0900
hatenablog://entry/6653812171404829118
読書
-
【サイト改善レポート】参照元とランディングページから改善ポイントを洗い出す
https://31webcreation.hatenablog.com/entry/reffer_x_lp_1 <p><a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a>アナリティクスを使って数値は追いかけているが、実際にどうやって改善点を洗い出せばいいのか分からないという方もいるのではないでしょうか。</p>
<p>そこで、今回は分かりやすく、効果が期待できる【<a class="keyword" href="http://d.hatena.ne.jp/keyword/%BB%B2%BE%C8%B8%B5">参照元</a>】と【ランディングページ】のセッション数と<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C4%BE%B5%A2%CE%A8">直帰率</a>からサイトの改善ページを考えていきたいと思います。</p>
<h3>なぜ<a class="keyword" href="http://d.hatena.ne.jp/keyword/%BB%B2%BE%C8%B8%B5">参照元</a>とランディングページを見るのか?</h3>
<p>ユーザーはどこからあなたのサイトに訪れるのでしょうか?</p>
<ul>
<li>他のサイトに貼ってあったあなたのサイトへのリンクから</li>
<li><a class="keyword" href="http://d.hatena.ne.jp/keyword/google">google</a>検索で表示されたあなたのサイトの検索結果から</li>
<li><a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%E1%A1%BC%A5%EB%A5%DE%A5%AC%A5%B8%A5%F3">メールマガジン</a>に記載されたサイトへのリンクから</li>
</ul>
<p>などいろいろなところから来ていることが考えられます。</p>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/%BB%B2%BE%C8%B8%B5">参照元</a>を見ることによって、これらの「どこから来ているのか?」を見ることができます。</p>
<p>また、ランディングページを見ることによってサイトのどのページに訪れているかが分かります。</p>
<p>どこから来て、どのページを見ているのかを見ることで、ユーザーが何を望んでサイトに訪れているのか、その望んでいるものがランディングページに記載されているのかといった仮説をたてることができます。</p>
<p>また、<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C4%BE%B5%A2%CE%A8">直帰率</a>を見ることによって、他のページやCVページヘの誘導ができているかを見ることができます。</p>
<p>ここでセッション数も合わせて見る理由は、改善の<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%A4%A5%F3%A5%D1%A5%AF">インパク</a>トを測る一つの指標として利用します。</p>
<p>例えば、100セッションのページと10,000セッションのページであれば、1%の<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C4%BE%B5%A2%CE%A8">直帰率</a>改善ができた場合、100セッションだと1セッションしか変わらないのに対して、10,000セッションであれば100セッション変わることになります。</p>
<p>せっかく改善しても効果の薄い施策よりは<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%A4%A5%F3%A5%D1%A5%AF">インパク</a>トのあるものを実行すべきです。</p>
<p>そのため、今回はセッション数と<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C4%BE%B5%A2%CE%A8">直帰率</a>を見ていきます。</p>
<h3><a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a> アナリティクス<a class="keyword" href="http://d.hatena.ne.jp/keyword/API">API</a>を使ってデータを取得</h3>
<p>このブログを見ていただいている方は知っているかと思いますが、本ブログでの<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a>アナリティクスデータは <a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a> SpreadSheet を使って取得・表示します。</p>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a>アナリティクス<a class="keyword" href="http://d.hatena.ne.jp/keyword/API">API</a>という<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%D7%A5%E9%A5%B0%A5%A4%A5%F3">プラグイン</a>を使って自動で取得できるようにしていきます。</p>
<p>これは毎月行う、または改善施策の前後数週間〜数ヶ月で数値を比較する場合などを少ない手間で行うために使います。</p>
<p>それではやっていきましょう。</p>
<p>※ <a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a> アナリティクス<a class="keyword" href="http://d.hatena.ne.jp/keyword/API">API</a> の基本的な使い方はこちらから</p>
<p><a href="http://31webcreation.hatenablog.com/entry/create-base-of-monitoring-report">【Googleアナリティクス】無料で使えるレポート作成ツールでレポートに必要なデータを取得する</a></p>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a> SpreadSheetの設定は以下のようになります。<br />※ 指標は以降でコピペできるようにしてあります。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160703192411p:plain" src="https://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160703/20160703192411.png" alt="f:id:ikdtty0423:20160703192411p:plain" width="488" /></p>
<p>上記設定を見ていきます。</p>
<p>まず【Start Date】と【End Date】は分析したい期間に合わせて設定してください。月ごとであったり、サイト改善の場合は改善の前後で比較する期間を選択してください。</p>
<p>改善の際は、十分なセッション数のボリュームがないと効果があったかどうかがわかりにくいので、そちらの点も注意して期間を設定してください。</p>
<p>次に【Metrics】を見ていきます。設定しているのは以下ですのでコピーして使ってください。</p>
<pre><code>ga:sessions
ga:users
ga:newUsers
ga:pageviewsPerSession
ga:bounceRate
ga:sessionDuration
ga:goal1Completions
ga:goal1ConversionRate</code></pre>
<p>上から、セッション数、ユーザー数、新規ユーザー数、ページ/セッション、<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C4%BE%B5%A2%CE%A8">直帰率</a>、平均セッション時間、コンバージョン数、コンバージョン率 となります。</p>
<p>セッション数やユーザー数で「量」を見て、新規ユーザー数やページ/セッションなどでその「質」を見ます。そしてコンバージョンによって「成果」を見ます。</p>
<p>※ コンバージョン指標の中にある 1 はご自身の設定によって変えてください。<br />ex) goal2Completions, goal4Completions など</p>
<p>次は【Dimensions】です。設定しているのは以下となります。</p>
<pre><code>ga:sourceMedium
ga:landingPagePath</code></pre>
<p>上が<a class="keyword" href="http://d.hatena.ne.jp/keyword/%BB%B2%BE%C8%B8%B5">参照元</a>/メディア、下がランディングページを表しています。</p>
<p>最後の【Sort】はセッション数を多い順に並び替えています。</p>
<pre><code>-ga:sessions</code></pre>
<p>ここまで入力が完了したら、以下を実行してデータを取得しましょう。</p>
<p> </p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160522153102p:plain" src="https://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160522/20160522153102.png" alt="f:id:ikdtty0423:20160522153102p:plain" /></p>
<p>このレポートを実行すると以下のように新しいSpreadSheetが作成されデータを取得することができます。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160703194106p:plain" src="https://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160703/20160703194106.png" alt="f:id:ikdtty0423:20160703194106p:plain" /></p>
<p>ひとまず、これを日本語化して見出しに色を付けわかりやすくしたのが以下の表です。</p>
<p>数値はそのままコピーしています。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160703194733p:plain" src="https://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160703/20160703194733.png" alt="f:id:ikdtty0423:20160703194733p:plain" /></p>
<p>色は、参照メディアとランディングページを軸にして、セッション数などの量を黄色、ページ/セッションなどの質をオレンジ、CV・CV率の成果を赤としています。</p>
<h3>表の見方</h3>
<p>全体として<a class="keyword" href="http://d.hatena.ne.jp/keyword/%BB%B2%BE%C8%B8%B5">参照元</a>とランディングページから、どんなサイトから訪れている人が多いのか、どこのページから見始めているのか(ランディング)を確認します。</p>
<p>まず注目するのは量の部分です。どんなにサイト改善を進めていても、量が少なければ改善<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%A4%A5%F3%A5%D1%A5%AF">インパク</a>トは小さいものになります。</p>
<p>次に見るのは成果です。こちらも量がどんなに多くても成果になっていなければ意味がなく、逆にCVしているだろうと思っていたページが想定通り成果を生み出しているかどうかを確認します。</p>
<p>そして最後に改善することで成果を生みそうなページの質を見ていきます。</p>
<p>特に注目すべきは<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C4%BE%B5%A2%CE%A8">直帰率</a>で、よりサイトのことを知ってもらうためにも他のページヘの遷移が大丈夫かを確認する指標となります。</p>
<h3>改善のポイント</h3>
<p>サイトにもよりますが、十分な量がある場合は上位20位くらいに絞って改善していきましょう。量が少ない場合は効果が大きそうな1,2ページに絞ってまずやってみることもいいと思います。</p>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/%C4%BE%B5%A2%CE%A8">直帰率</a>が高い場合は、そのページに来ているユーザーのニーズに合わせて他のページに遷移させるような導線を用意したり、ファーストビューのナビゲーションの配置や見やすさ・ページの内容がすぐに分かるようになっているかなどを実際のページで確認して改善施策を立てていきましょう。</p>
<p>注意して欲しいのは、<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C4%BE%B5%A2%CE%A8">直帰率</a>が高くても問題ない場合もあるということです。</p>
<p>1ページで完結する読み物コンテンツ、用語集やFAQなどはユーザーがそのページのみで満足して直帰することが多い可能性があります。</p>
<p>こういったページでも、それに関連したコンテンツへの導線を設けることで回遊を促しサイトを知ってもらうために改善をしてみましょう。</p>
<p>サイト改善を行うにあたってベストな答えを見出すことは難しいです。そのため、仮説を立ててそれをどう改善していくのかということを繰り返し行なっていくことが大事になってきます。</p>
<p>また、他の方に相談しながら複数の視点で仮説の精度を上げていくことも大事となります。</p>
<p>今回の分析ではシンプルで<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%A4%A5%F3%A5%D1%A5%AF">インパク</a>トがあるページを洗い出すことができますので、ご自身のサイトで是非試してみてください。</p> Mon, 04 Jul 2016 06:00:00 +0900
hatenablog://entry/6653812171403799028
Googleアナリティクス
分析レポート
-
【Googleアナリティクス API】新規ユーザーとリピーターのセグメントでサイトを分析する
https://31webcreation.hatenablog.com/entry/new-repeat-user-report <p>サイトを運営している目的はそれぞれあり、その成果を上げるためにアナリティクスを使って分析するのではないでしょうか?</p>
<p>今回はサイトの目的を【CVアップ】とし、それを上げるための一つの分析の型として「新規・リピートユーザーでのセグメント分析」をやってみたいと思います。</p>
<p>また、今回も<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a>アナリティクス <a class="keyword" href="http://d.hatena.ne.jp/keyword/API">API</a> を使ってレポートを作成し、毎月のデータを自動で作成し、追えるようにしていきたいと思います。</p>
<h3>Query Explorer で 新規ユーザーとリピートユーザーのセグメントを確認</h3>
<p><a href="https://ga-dev-tools.appspot.com/query-explorer/">Query Explorer — Google Analytics Demos & Tools</a></p>
<p>ご自身で設定しているCVを Query explorer から確認するにはこちらをご覧ください。</p>
<p><a href="http://31webcreation.hatenablog.com/entry/get-conversion-with-google-analytics-api">【Googleアナリティクス API】目標値(CV)の取得 - 31歳から始めたウェブ解析・プログラマーという仕事</a></p>
<p>今回の例では、【<span style="color: #444444; font-family: Arial; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">ga:goal1Completions</span>】を使います。複数取得することも可能ですので、分析したいCV指標を選択してください。</p>
<p>また、セグメントを確認するのも同様に Query explorer の 【segment】をクリックし【New Users】と【Returning Users】の【gaid】を確認してください。</p>
<p>デフォルトのセグメントですので、基本的には同じ gaid だと思いますが、念のためご確認ください。</p>
<p>以下より、New User は【gaid::-2】、Returning User は【gaid::-3】となります。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160611194432p:plain" src="https://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160611/20160611194432.png" alt="f:id:ikdtty0423:20160611194432p:plain" /></p>
<h3>新規ユーザーとリピートユーザーデータの注意点</h3>
<p>今回は新規ユーザーとリピートユーザーのデータを分析します。</p>
<p>しかし、<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a> アナリティクスのセグメントにおける<span style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">New User と Returning User は<span style="color: #dd830c;">セッション数</span><span style="color: #000000;">になっているので注意してください。</span></span></p>
<p>数値のチェックをしていて、どうも数値データの一致が取れないなと思ったら、この<span style="color: #dd830c;">ユーザー</span>という言葉に間違って解釈をしていることがあるので注意しましょう。</p>
<h3>サイト全体と新規ユーザー、リピートユーザーのデータを取得</h3>
<p>では、<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a> アナリティクス <a class="keyword" href="http://d.hatena.ne.jp/keyword/API">API</a> を使ってデータを取ってきます。</p>
<p>セグメント分析するときは以下の指標を見ていきましょう。</p>
<p><span style="font-size: 80%;">※ 各指標については別途記事にします。</span></p>
<ul>
<li><span style="color: #333333; font-family: 'Helvetica Neue', Arial, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 20px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">PV</span></li>
<li><span style="color: #333333; font-family: 'Helvetica Neue', Arial, sans-serif; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 20px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">セッション数</span></li>
<li>ユーザー数</li>
<li>平均滞在時間</li>
<li><a class="keyword" href="http://d.hatena.ne.jp/keyword/%C4%BE%B5%A2%CE%A8">直帰率</a></li>
<li>新規率</li>
<li>CV数</li>
</ul>
<p>このそれぞれの指標を<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a>アナリティクス<a class="keyword" href="http://d.hatena.ne.jp/keyword/API">API</a>で取得するには以下のようにします。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160620220331p:plain" src="https://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160620/20160620220331.png" alt="f:id:ikdtty0423:20160620220331p:plain" /></p>
<p> </p>
<p>全体のCV(AllConversion)を計測し、【Segment】に新規ユーザー(gaid::-2)とリピートユーザー(gaid::-3)を設定します。</p>
<p><span style="font-size: 80%;">※ 新規ユーザーとリピートユーザーを足せば全体になりますが、吐き出したデータをそのまま使いたいので全体も出すようにしています。</span></p>
<p><span style="font-size: 80%;">※ ga:percentNewSessions は新規では 100%, リピーターでは 0% になるので、指標として設定しても意味がないのですが、今後他のセグメントでレポートを作る際に統一したいので入れています。<br /></span></p>
<p>また、メトリックスは先ほど説明した7つの指標を設定します。</p>
<pre><code>ga:pageviews<br />ga:sessions<br />ga:users<br />ga:avgSessionDuration<br />ga:bounceRate<br />ga:percentNewSessions<br />ga:goal1Completions</code></pre>
<p>入力が完了したら、メニュー【アドオン】→【<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google%20Analytics">Google Analytics</a>】→【Run reports】でデータを取得しましょう。</p>
<p> </p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515114428p:plain" src="https://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515114428.png" alt="f:id:ikdtty0423:20160515114428p:plain" /></p>
<p> </p>
<h3>取得データの分析</h3>
<p>各指標を新規ユーザーとリピートユーザーで比較していきます。</p>
<p>CVに貢献しているのはどちらか、それぞれのユーザーに指標の数値に差はないか、差があればなぜその差が生まれているのかの仮説を立てて検証 → 改善につなげていきます。</p>
<p><span style="font-size: 80%;">※ データを見るときは月別にグラフにしたりすると視覚的に把握することができます。</span></p>
<p>新規ユーザーとリピートユーザーで比較する時も、おそらく新規とリピートでは行動に差があるのでは?という仮説を持ってデータの分析を始めると思います。</p>
<p>そのため、ここでもそれを確認し、さらに深い分析・仮説立てに発展させてください。</p>
<h3>それ以外のセグメント</h3>
<p>今回は新規・リピートユーザーについてのセグメント分け・分析を行ってきましたが、次回以降は流入元別であったり、ランディングページ別でのセグメント分けと分析をしていこうと思います。</p>
<p>また、レポートで取り上げている7つの指標についてもまとめていきたいと思います。</p> Tue, 21 Jun 2016 07:00:00 +0900
hatenablog://entry/6653812171400625815
Googleアナリティクス
分析レポート
-
【Googleアナリティクス API】流入元ごと、セグメントごとにデータを取得する
https://31webcreation.hatenablog.com/entry/get-segment-with-google-analytics-api <p>最終回は流入元ごと、セグメントごとにデータを取得していきます。</p>
<p>流入元は自然検索と<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%EA%A5%D5%A5%A1%A5%E9">リファラ</a>ーを見ていきます。</p>
<p>また、セグメントはViewごとの設定しているものがあると思うので、それによる違いも含め取得方法を見ていきます。</p>
<h3>流入元別のデータを取得する</h3>
<p>流入元ごとに見ていくには前回同様【Filters】を使います。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160604194909p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160604/20160604194909.png" alt="f:id:ikdtty0423:20160604194909p:plain" /></p>
<p>自然検索の場合は【ga:sourceMedium=@organic】を、<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%EA%A5%D5%A5%A1%A5%E9">リファラ</a>ーの場合は【ga:sourceMedium=@referral】を入力します。</p>
<p>以下の例では自然検索の場合を表示しています。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160604211433p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160604/20160604211433.png" alt="f:id:ikdtty0423:20160604211433p:plain" /></p>
<h3>セグメントごとにデータを取得する</h3>
<p>まず設定しているセグメントを確認しましょう。<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a> アナリティクスの Query Explorer を使います。</p>
<p><a href="https://ga-dev-tools.appspot.com/query-explorer/">Query Explorer — Google Analytics Demos & Tools</a></p>
<p>上記をクリックしていただき、ログインします。</p>
<p>ログインしたら下にスクロールし、【Select a view】からデータを取得したいViewを指定します。以下はこのブログのViewを指定しています。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160604213217p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160604/20160604213217.png" alt="f:id:ikdtty0423:20160604213217p:plain" /></p>
<p> </p>
<p>そして、その下にある【Set the query parameters】の【segment】の部分を選択してください。</p>
<p> </p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160604213706p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160604/20160604213706.png" alt="f:id:ikdtty0423:20160604213706p:plain" /></p>
<p>すると以下の画面のように設定しているセグメント一覧が表示されますので、データ取得したいセグメントを選択してください。</p>
<p>以下の画面ではOrganic Trafficを選択しています。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160604213837p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160604/20160604213837.png" alt="f:id:ikdtty0423:20160604213837p:plain" /></p>
<p> </p>
<p>選択すると以下のように【gaid::-5】という表示に変わります。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160604214002p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160604/20160604214002.png" alt="f:id:ikdtty0423:20160604214002p:plain" /></p>
<p> </p>
<p>これを<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a> spreadsheet <a class="keyword" href="http://d.hatena.ne.jp/keyword/API">API</a> の【segment】にコピー & ペーストします。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160604214445p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160604/20160604214445.png" alt="f:id:ikdtty0423:20160604214445p:plain" /></p>
<p> </p>
<p>セグメントはViewによって変わってくるので適宜選択してください。</p>
<p>メニューの【アドオン】→【<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google%20Analytics">Google Analytics</a>】→【Run reports】をクリックするとデータを取得することができます。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515114428p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515114428.png" alt="f:id:ikdtty0423:20160515114428p:plain" /></p>
<p> </p>
<p>全7回にわたって <a class="keyword" href="http://d.hatena.ne.jp/keyword/Google%20analytics">Google analytics</a> <a class="keyword" href="http://d.hatena.ne.jp/keyword/API">API</a>を使ってデータの自動取得を行ってきました。</p>
<p>基本的なデータの取得はできるようになったと思いますので、レポートに合わせて適宜データを取得してください。</p>
<p>今後はこれらを使って更にデータ取得・レポート作成を進めていきたいと思います。</p>
<h4 style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 27.2px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;">1. <a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%E2%A5%CB%A5%BF%A5%EA%A5%F3%A5%B0">モニタリング</a>レポートとは?</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/2016/05/04/115412">【Googleアナリティクス】モニタリングレポートと作成自動化の流れ</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">2. データの自動取得</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1; outline: 0px;" href="http://31webcreation.hatenablog.com/entry/create-base-of-monitoring-report">【Googleアナリティクス】無料で使えるレポート作成ツールでレポートに必要なデータを取得する</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">3. データの集計</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/monthly-summary-with-ga">【Googleアナリティクス API】取得したデータを月別に集計する</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">4. グラフ化</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/monthly-graph-with-ga">【Googleアナリティクス API】グラフを作成する</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">5. 目標値の取得(CV) </h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/get-conversion-with-google-analytics-api">【Googleアナリティクス API】目標値(CV)の取得</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">6. 記事ごと、<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C7%A5%A3%A5%EC%A5%AF%A5%C8">ディレクト</a>リごとのデータ取得</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1; outline: 0px;" href="http://31webcreation.hatenablog.com/entry/get-page-directory-data-with-google-analytics-api">【Googleアナリティクス API】記事ごと、ディレクトリごとにデータを取得する</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">7. 流入元ごと、セグメントごとのデータ取得 ← 今回</h4> Wed, 08 Jun 2016 07:00:00 +0900
hatenablog://entry/6653812171399647389
Googleアナリティクス
-
【Googleアナリティクス API】記事ごと、ディレクトリごとにデータを取得する
https://31webcreation.hatenablog.com/entry/get-page-directory-data-with-google-analytics-api <p>今回は記事ごと、<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C7%A5%A3%A5%EC%A5%AF%A5%C8">ディレクト</a>リごとのデータ取得をやっていきます。</p>
<p>ブログをやっていれば記事ごとでどのくらいPVがあって、滞在時間・<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C4%BE%B5%A2%CE%A8">直帰率</a>などが気になるところではないでしょうか?</p>
<p>またサイトを運営している場合はURLごとにコンテンツを分けていることが多いので、<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C7%A5%A3%A5%EC%A5%AF%A5%C8">ディレクト</a>リごとにデータを見たいと思います。</p>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a> アナリティクス <a class="keyword" href="http://d.hatena.ne.jp/keyword/API">API</a> を使って自動的にデータを取得し、記事やサイトの状況を把握していきましょう!</p>
<h3> 記事ごとのデータを取得する</h3>
<p>例えば、前回のブログ記事 ↓↓ のデータを取得してみましょう。</p>
<p><a href="http://31webcreation.hatenablog.com/entry/get-conversion-with-google-analytics-api">http://31webcreation.hatenablog.com/entry/get-conversion-with-google-analytics-api</a></p>
<p>前回までの<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a> SpreadSheetの入力に追加していきます。追加するのは【Filters】の部分です。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160604194909p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160604/20160604194909.png" alt="f:id:ikdtty0423:20160604194909p:plain" /></p>
<p>取得したい記事のURL後半部分【<span style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">/entry/get-conversion-with-<a class="keyword" href="http://d.hatena.ne.jp/keyword/google">google</a>-analytics-<a class="keyword" href="http://d.hatena.ne.jp/keyword/api">api</a></span>】を使って【ga:pagePath=~^/entry/get-conversion-with-<a class="keyword" href="http://d.hatena.ne.jp/keyword/google">google</a>-analytics-<a class="keyword" href="http://d.hatena.ne.jp/keyword/api">api</a>】を【Filters】に入力してください。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160604195330p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160604/20160604195330.png" alt="f:id:ikdtty0423:20160604195330p:plain" /></p>
<p>【ga:pagePath】は指定したURLのデータを取得することを意味しています。</p>
<p>【=~】は<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C0%B5%B5%AC%C9%BD%B8%BD">正規表現</a>を表す<a class="keyword" href="http://d.hatena.ne.jp/keyword/%B1%E9%BB%BB%BB%D2">演算子</a>ですが、難しいので興味がある方は調べてみてください。【^】は<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C0%B5%B5%AC%C9%BD%B8%BD">正規表現</a>の書き方でURLの始まりを指定します。こちらも難しいので興味がある方は調べてみてください。</p>
<p>まとめると、【ga:pagePath=~^】はそれ以降に続く文字列で始まるURLのデータを取得してくださいという意味になります。</p>
<p>そのため、この後に【/】から始まるURL部分を記載してください。</p>
<p>それ以外のページのデータを取得するときも同様で、<span style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">【ga:pagePath=~^】以降に【/】で始まるページのURLを記載してください。</span></p>
<h3><a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C7%A5%A3%A5%EC%A5%AF%A5%C8">ディレクト</a>リごとのデータを取得する</h3>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C7%A5%A3%A5%EC%A5%AF%A5%C8">ディレクト</a>リごとのデータを取得する場合も<span style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">【ga:pagePath=~^】の後に続けて記載します。</span></p>
<p>例えば、記事の上の<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C7%A5%A3%A5%EC%A5%AF%A5%C8">ディレクト</a>リ【/entry/】のデータを取得したい場合はこれを入力し、【ga:pagePath=~^/entry/】を追記しましょう。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160604201458p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160604/20160604201458.png" alt="f:id:ikdtty0423:20160604201458p:plain" /></p>
<p> </p>
<p>記事ごとも<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C7%A5%A3%A5%EC%A5%AF%A5%C8">ディレクト</a>リごとも、【Filters】に設定【ga:pagePath=~】を記載してメニュー【アドオン】→【<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google%20Analytics">Google Analytics</a>】→【Run reports】をクリックすることでデータを取得することができます。</p>
<p> </p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160522153102p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160522/20160522153102.png" alt="f:id:ikdtty0423:20160522153102p:plain" /></p>
<p> </p>
<p>取得できましたでしょうか?取得したデータに合わせてグラフ化などを行っていただき視覚的に理解できるようにしていただければと思います。</p>
<p>次回は流入元ごと、セグメントごとにデータを取得していきます。</p>
<p> </p>
<h4 style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 27.2px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;">1. <a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%E2%A5%CB%A5%BF%A5%EA%A5%F3%A5%B0">モニタリング</a>レポートとは?</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/2016/05/04/115412">【Googleアナリティクス】モニタリングレポートと作成自動化の流れ</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">2. データの自動取得</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1; outline: 0px;" href="http://31webcreation.hatenablog.com/entry/create-base-of-monitoring-report">【Googleアナリティクス】無料で使えるレポート作成ツールでレポートに必要なデータを取得する</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">3. データの集計</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/monthly-summary-with-ga">【Googleアナリティクス API】取得したデータを月別に集計する</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">4. グラフ化</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/monthly-graph-with-ga">【Googleアナリティクス API】グラフを作成する</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">5. 目標値の取得(CV) </h4>
<p><a href="http://31webcreation.hatenablog.com/entry/get-conversion-with-google-analytics-api">【Googleアナリティクス API】目標値(CV)の取得</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">6. 記事ごと、<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C7%A5%A3%A5%EC%A5%AF%A5%C8">ディレクト</a>リごとのデータ取得 ← 今回</h4>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">7. 流入元ごと、セグメントごとのデータ取得</h4>
<p><a href="http://31webcreation.hatenablog.com/entry/get-segment-with-google-analytics-api">【Googleアナリティクス API】流入元ごと、セグメントごとにデータを取得する</a></p> Mon, 06 Jun 2016 07:00:00 +0900
hatenablog://entry/6653812171399632405
Googleアナリティクス
-
【Googleアナリティクス API】目標値(CV)の取得
https://31webcreation.hatenablog.com/entry/get-conversion-with-google-analytics-api <p>今回は<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a>アナリティクス<a class="keyword" href="http://d.hatena.ne.jp/keyword/API">API</a>を使って目標値(CV)を取得する方法をご紹介します。</p>
<p>目標値はお問合せや資料DL、ページ閲覧数など、各サイトで設定するものが違います。それを<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a>アナリティクス<a class="keyword" href="http://d.hatena.ne.jp/keyword/API">API</a>で取得していきます。</p>
<h3>設定している目標値を確認する</h3>
<p>先ほどご紹介したとおり、目標値はサイトごとに異なります。</p>
<p>また、サイトの運営が長い場合、目標値を複数設定したり、削除したりしている場合があり、まずどの目標値を取得するのかを確認します。</p>
<p>設定している目標値は以下のサイトから確認します。</p>
<p><a href="https://ga-dev-tools.appspot.com/query-explorer/">Query Explorer — Google Analytics Demos & Tools</a></p>
<p>上記リンクをクリックすると以下の画面になりますので、【Click here to authorize →】をクリックしてデータを取得したいアカウントでログインしてください。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160522145214p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160522/20160522145214.png" alt="f:id:ikdtty0423:20160522145214p:plain" /></p>
<p>ログインすると元いた画面に戻りますので、下にスクロールしてください。</p>
<p>【Select a view】では、取得したいアナリティクスアカウント、プロパティ、ビューを選択してください。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160522145909p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160522/20160522145909.png" alt="f:id:ikdtty0423:20160522145909p:plain" /></p>
<p>次に、その下にある【Set the query parameters】部分を入力していきます。</p>
<p>このとき注目するのは【metrics】の部分です。ここに<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%DE%A5%A6%A5%B9%A5%AB%A1%BC%A5%BD%A5%EB">マウスカーソル</a>をあわせクリックしてください。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160522150225p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160522/20160522150225.png" alt="f:id:ikdtty0423:20160522150225p:plain" /></p>
<p>クリックすると下に<a class="keyword" href="http://d.hatena.ne.jp/keyword/%B8%F5%CA%E4">候補</a>一覧が表示されるので、この状態で「conversion」と入力するとCV一覧を表示されます。</p>
<p>その中で、取得したいCVを選択してください。<br /><span style="font-size: 80%;">※ 今回は例として3ページ以上見た人をCVとしています。</span></p>
<p>選択するときはCVの完了数値を取得したいので、下に小さくある【ga:goal1Completions】の【Completions】があるものを選択してください。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160522150602p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160522/20160522150602.png" alt="f:id:ikdtty0423:20160522150602p:plain" /></p>
<p> 選択すると【metrics】の欄に「ga:goal1Completions」が表示されます。</p>
<p><span style="font-size: 80%;">※真ん中にある「1」という数字が取得するCVによって2,3などと変わっていきます。</span></p>
<p>これで値が正しく取得できるかを確認するため、【start-date】【end-date】を設定し、【Run Query】をクリックしてください。</p>
<p>月別に値を確認することが多いと思うので、1ヶ月単位で確認するのがやりやすいと思います。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160522151701p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160522/20160522151701.png" alt="f:id:ikdtty0423:20160522151701p:plain" /></p>
<p> 【Run Query】をクリックすると、そのすぐ下に以下の画面が表示されます。</p>
<p>ここで、【Goal 1 Completions】の値を確認してください。(画面右下赤枠に数値が表示されます。)</p>
<p>複数CVを確認したい場合は、上記画面の【metrics】を再度選択し、続けてCVを選択すると複数のCVをまとめて取得することができます。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160522152233p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160522/20160522152233.png" alt="f:id:ikdtty0423:20160522152233p:plain" /></p>
<p>これで、正しい値が取得できているかを確認してください。</p>
<h3><a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a>アナリティクス<a class="keyword" href="http://d.hatena.ne.jp/keyword/API">API</a>でCVの値を取得する</h3>
<p>さて、いよいよCV値を取得します。</p>
<p>先ほど確認したCVの【<span style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">ga:goal1Completions</span>】という値をコピーします。<br /><span style="font-size: 80%;">※ 真ん中にある数字「1」は取得したいCVによって変わります。</span></p>
<p>そして、前回まで作成しているSpreadSheetの【<span style="color: #222222; font-family: arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">Report Configuration</span>】シートを開き、【Metrics】のセルの一番下にコピーした【<span style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">ga:goal1Completions</span>】を追加します。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160522153210p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160522/20160522153210.png" alt="f:id:ikdtty0423:20160522153210p:plain" /></p>
<p> </p>
<p>そして、メニューの【アドオン】→【<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google%20Analytics">Google Analytics</a>】→【Run reports】をクリックします。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160522153102p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160522/20160522153102.png" alt="f:id:ikdtty0423:20160522153102p:plain" /></p>
<p> </p>
<p>すると【<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>】のシートの一番右にCVの値が追加されます。</p>
<p><span style="font-size: 80%;">※【<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>】は上記画像の【Report Name】で設定した名前となります。</span></p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160522153545p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160522/20160522153545.png" alt="f:id:ikdtty0423:20160522153545p:plain" width="200px" /></p>
<p>あとは前回同様にグラフ化などを行えば自動でCVデータを取得 → グラフ化することが可能です。</p>
<p>いかがでしたでしょうか?</p>
<p>普段レポート作成のときに使っている基本的な値は今回ですべて取得でき、グラフ化まで自動的に作成されるようになります。</p>
<p>次回以降の2回はすこし応用してブログの記事ごと、サイトの<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C7%A5%A3%A5%EC%A5%AF%A5%C8">ディレクト</a>リごとのデータ取得と自然検索、<a class="keyword" href="http://d.hatena.ne.jp/keyword/SEM">SEM</a>などの流入元ごとのデータ取得をやっていきます。</p>
<p> </p>
<h4 style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 27.2px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;">1. <a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%E2%A5%CB%A5%BF%A5%EA%A5%F3%A5%B0">モニタリング</a>レポートとは?</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/2016/05/04/115412">【Googleアナリティクス】モニタリングレポートと作成自動化の流れ</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">2. データの自動取得</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1; outline: 0px;" href="http://31webcreation.hatenablog.com/entry/create-base-of-monitoring-report">【Googleアナリティクス】無料で使えるレポート作成ツールでレポートに必要なデータを取得する</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">3. データの集計</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/monthly-summary-with-ga">【Googleアナリティクス API】取得したデータを月別に集計する</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">4. グラフ化</h4>
<p><a href="http://31webcreation.hatenablog.com/entry/monthly-graph-with-ga">【Googleアナリティクス API】グラフを作成する</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">5. 目標値の取得(CV) ← 今回</h4>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">6. 記事ごと、<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C7%A5%A3%A5%EC%A5%AF%A5%C8">ディレクト</a>リごとのデータ取得</h4>
<p><a href="http://31webcreation.hatenablog.com/entry/get-page-directory-data-with-google-analytics-api">【Googleアナリティクス API】記事ごと、ディレクトリごとにデータを取得する</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">7. 流入元ごと、セグメントごとのデータ取得</h4>
<p><a style="color: #8bc8e1; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" href="http://31webcreation.hatenablog.com/entry/get-segment-with-google-analytics-api">【Googleアナリティクス API】流入元ごと、セグメントごとにデータを取得する</a></p> Mon, 23 May 2016 08:00:00 +0900
hatenablog://entry/6653812171397450073
Googleアナリティクス
-
【Googleアナリティクス API】グラフを作成する
https://31webcreation.hatenablog.com/entry/monthly-graph-with-ga <p>前回、月別にデータをまとめたので、今回はそれをグラフ化していきます。エクセルでグラフを作り慣れている方は、同様に作成できるのでやってみてください。</p>
<p>今回の内容も以下のURLより確認することができます。</p>
<p><a href="https://docs.google.com/spreadsheets/d/1hEbSggcZomZlTxfB_SrPe7INHPF4URbVnfK3sBBMSX4/edit?usp=sharing">160518_ブログ_GAdata - Google スプレッドシート</a></p>
<h3>グラフ用のシートを作成する</h3>
<p>画面下にある【+】マークをクリックし、新しいシートを追加します。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515122457p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515122457.png" alt="f:id:ikdtty0423:20160515122457p:plain" width="400px" /></p>
<p>ここに各指標のグラフを作成していきます。</p>
<h3>グラフを作成する</h3>
<p>メニューにある【挿入】→【グラフ】を選択してください。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515144943p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515144943.png" alt="f:id:ikdtty0423:20160515144943p:plain" width="400px" /></p>
<p>すると以下の画面が現れますので、格子マーク(赤枠)をクリックしてグラフ化するデータを追加していきます。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515145348p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515145348.png" alt="f:id:ikdtty0423:20160515145348p:plain" /></p>
<p> </p>
<p>すると以下の画面が現れますので、【データ】下の赤枠を選択し、すべて削除します。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515145452p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515145452.png" alt="f:id:ikdtty0423:20160515145452p:plain" width="400px" /></p>
<p>その状態で月別集計したシートを選択し、該当データを選択します。最初はPVのグラフを作るので、C列、D列を選択します。</p>
<p>データの選択が終わったら【OK】をクリックしてください。</p>
<p> </p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515145829p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515145829.png" alt="f:id:ikdtty0423:20160515145829p:plain" /></p>
<p>クリックすると元の画面に戻るので、グラフの種類【折れ線】を選択します。<br />すると右側にデータが現れます。<br /><span style="font-size: 80%;">※ 数値はダミーデータです。</span></p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515150252p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515150252.png" alt="f:id:ikdtty0423:20160515150252p:plain" /></p>
<p> </p>
<p>次に【カスタマイズ】をクリックして、グラフのタイトルや軸の表示を調整します。</p>
<p>この辺りは好みなので、適宜修正をお願いします。</p>
<p>すべての入力が終わったら【完了】をクリックします。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515150514p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515150514.png" alt="f:id:ikdtty0423:20160515150514p:plain" /></p>
<p>するとグラフが表示されます。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515150736p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515150736.png" alt="f:id:ikdtty0423:20160515150736p:plain" /></p>
<h3>グラフ作成の注意点</h3>
<p>2つ目以降のデータを選択する際、離れた列を選択する必要があります。<br />(例えば、セッション数であれば月の列とセッション数の列)</p>
<p>その際はデータを選択する際に先に月データ(C列)を選択します。</p>
<p>その次に【別の範囲を追加】をクリックします。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515151300p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515151300.png" alt="f:id:ikdtty0423:20160515151300p:plain" width="400px" /></p>
<p> </p>
<p>すると入力する枠がもう一つ追加されるので、そこにE列(セッション数)を選択し、【OK】をクリックするとうまくいきます。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515151405p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515151405.png" alt="f:id:ikdtty0423:20160515151405p:plain" width="400px" /></p>
<p>それ以外のデータでも同じ手順でグラフ化してみてください。</p>
<p>基本的なデータ取得とグラフ化の流れをやってみましたが、いかがでしたでしょうか?</p>
<p>次回は各サイトで設定している目標値の取得とそのグラフ化をやってみます。</p>
<h4 style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 27.2px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;">1. <a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%E2%A5%CB%A5%BF%A5%EA%A5%F3%A5%B0">モニタリング</a>レポートとは?</h4>
<p><a href="http://31webcreation.hatenablog.com/entry/2016/05/04/115412">【Googleアナリティクス】モニタリングレポートと作成自動化の流れ</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">2. データの自動取得</h4>
<p><a href="http://31webcreation.hatenablog.com/entry/create-base-of-monitoring-report">【Googleアナリティクス】無料で使えるレポート作成ツールでレポートに必要なデータを取得する</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">3. データの集計</h4>
<p><a href="http://31webcreation.hatenablog.com/entry/monthly-summary-with-ga">【Googleアナリティクス API】取得したデータを月別に集計する</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">4. グラフ化 ← 今回</h4>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">5. 目標値の取得(CV)</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/get-conversion-with-google-analytics-api">【Googleアナリティクス API】目標値(CV)の取得</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">6. 記事ごと、<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C7%A5%A3%A5%EC%A5%AF%A5%C8">ディレクト</a>リごとのデータ取得</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1; outline: 0px;" href="http://31webcreation.hatenablog.com/entry/get-page-directory-data-with-google-analytics-api">【Googleアナリティクス API】記事ごと、ディレクトリごとにデータを取得する</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">7. 流入元ごと、セグメントごとのデータ取得</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" href="http://31webcreation.hatenablog.com/entry/get-segment-with-google-analytics-api">【Googleアナリティクス API】流入元ごと、セグメントごとにデータを取得する</a></p> Fri, 20 May 2016 07:00:00 +0900
hatenablog://entry/6653812171396204520
Googleアナリティクス
-
【Googleアナリティクス API】取得したデータを月別に集計する
https://31webcreation.hatenablog.com/entry/monthly-summary-with-ga <p>前回はデータ取得までやったので、これを日別に取得し、月別データでまとめるところまでやっていきます。</p>
<p>レポート作成は月ごとが多いと思うので今回はそれに合わせて作成しますが、週ごとなど報告形式に合わせて調整していただければと思います。</p>
<p>※ 今回の内容は以下にまとめてあります。</p>
<p><a href="https://docs.google.com/spreadsheets/d/1LpwlxrnnJXawvO2_ocDAuWelRugN4_QWmEFEBVp9Ops/edit?usp=sharing">160517_ブログ_GAdata - Google スプレッドシート</a></p>
<h3> 日別にデータを取得する</h3>
<p>前回は直近7日間のデータを取得しました。<br />これは以下の図の青枠で指定しています。この数字は削除してください。 </p>
<p>次に赤枠内に取得したい期間の日付を指定してください。</p>
<p>以下では、このブログのデータ取得を始めたのが11月からなので【Strat Date】にそのように記入していますが、それぞれに合わせて記入してください。</p>
<p>【End Date】はいつまでのデータを取得するかという意味ですが、未来の日付も指定できます。今期のデータをまとめるという意味で「2017/03/31」を記入しています。</p>
<p> </p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515120019p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515120019.png" alt="f:id:ikdtty0423:20160515120019p:plain" /></p>
<p> </p>
<p>これで取得するデータの日程を設定できたので、メニュー【アドオン】→【<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google%20Analytics">Google Analytics</a>】→【Run reports】とクリックしデータを取得しましょう。</p>
<p> </p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160424100950p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160424/20160424100950.png" alt="f:id:ikdtty0423:20160424100950p:plain" /></p>
<p> </p>
<p>すると指定した期間でのデータが取得できています。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515121330p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515121330.png" alt="f:id:ikdtty0423:20160515121330p:plain" /></p>
<h3>月別にデータを集計する</h3>
<p>次は日別のデータを月別でまとめていきます。</p>
<h4>集計のための下準備</h4>
<p>以下の図の【ga:date】の列を最後まで選択します。</p>
<p>選択した状態で【表示形式】→【数字】→【書式なしテキスト】を選択します。これはエクセルを使い慣れている人なら経験があると思いますがデータを検索するときに必要な処理となります。詳細は長くなるので興味がある方は調べてみてください。</p>
<p> </p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515122007p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515122007.png" alt="f:id:ikdtty0423:20160515122007p:plain" /></p>
<p> </p>
<h4>表の作成</h4>
<p>画面左下にある【+】ボタンから新しいシートを追加します。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515122457p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515122457.png" alt="f:id:ikdtty0423:20160515122457p:plain" width="400px" /></p>
<p>今回は基本的な指標ということで、以下のようにデータをまとめることにしました。<br /><span style="font-size: 80%;">※ 見た目は好みなので適宜修正してください。</span></p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515123113p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515123113.png" alt="f:id:ikdtty0423:20160515123113p:plain" /></p>
<p>B,C列には【年】と【月】を入れています。また、先ほど取得した指標をD列〜I列(緑)に入れるように表を作成し、J列〜L列(オレンジ)はデータ計算して率や平均時間を出すようにします。</p>
<h4>月別データの集計</h4>
<p>【Report Configuration】シートで【Report Name】を「<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>」としたので、「<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>」というシートに取得したデータが表示されていると思います。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515124513p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515124513.png" alt="f:id:ikdtty0423:20160515124513p:plain" /></p>
<p>【Report Name】を修正した方は、それに合わせて以下の数式を適宜修正してください。</p>
<p>最初に「PV」の値を集計します。D列3行目に以下の数式を入力してください。</p>
<p><em><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">=</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">sumifs</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">(</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #f7981d; background-color: #ffffff;">'<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>'!B$4:B$839</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">,</span> <span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #7e3794; background-color: #ffffff;">'<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>'!$A$4:$A$839</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">,</span> <span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #11a9cc; background-color: #ffffff;">B3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span class=" string " dir="auto" style="color: green; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">"-"</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #a61d4c; background-color: #ffffff;">C3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span class=" string " dir="auto" style="color: green; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">"-*"</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">)</span></em></p>
<p>数式の詳細は調べていただきたいのですが、最初の【<span style="color: #f7981d; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">'<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>'!B$4:B$839</span>】でどのセルの値を合計するのかを指定しています。この場合はPVなので、「<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>」シートのB列4〜839行目のデータを合計するという意味です。</p>
<p>行数はデータ取得のときに指定した日付で変わってくるので、それに合わせて修正してください。</p>
<p>次の【<span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #7e3794; background-color: #ffffff;">'<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>'!$A$4:$A$839</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">,</span> <span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #11a9cc; background-color: #ffffff;">B3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span class=" string " dir="auto" style="color: green; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">"-"</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #a61d4c; background-color: #ffffff;">C3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span class=" string " dir="auto" style="color: green; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">"-*"</span>】部分が集計する条件を指定しています。【<span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #7e3794; background-color: #ffffff;">'<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>'!$A$4:$A$839</span>】は「<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>」シートのA列4〜839行目のデータ(日付)を表しており、その日付の中で【<span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #11a9cc; background-color: #ffffff;">B3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span class=" string " dir="auto" style="color: green; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">"-"</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #a61d4c; background-color: #ffffff;">C3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span class=" string " dir="auto" style="color: green; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 13px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">"-*"</span>】にマッチするもの、つまり「B3」では年、「C3」では月を指定しており、「-*」は日付の部分は任意のものを取得しています。</p>
<p>それ以外の「セッション数、ユーザー数、新規ユーザー数、直帰数、滞在時間合計」も同様の考え方で3行目に以下の式を入力してください。</p>
<p><span style="font-size: 80%;">※ このファイルは後ほどまとめて公開しますのでお待ちください。</span></p>
<p>セッション数: <em><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">=</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">sumifs</span><span class=" default-formula-text-color match-paren" dir="auto" style="font-weight: bold; color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #e5e5e5;">(</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #f7981d; background-color: #ffffff;">'<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>'!C$4:C$839</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">,</span> <span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #7e3794; background-color: #ffffff;">'<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>'!$A$4:$A$839</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">,</span> <span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #11a9cc; background-color: #ffffff;">B3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span class=" string " dir="auto" style="color: green; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">"-"</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #a61d4c; background-color: #ffffff;">C3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span class=" string " dir="auto" style="color: green; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">"-*"</span><span class=" match-paren default-formula-text-color" dir="auto" style="font-weight: bold; color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #e5e5e5;">)</span></em><br />ユーザー数: <em><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">=</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">sumifs</span><span class=" default-formula-text-color match-paren" dir="auto" style="font-weight: bold; color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #e5e5e5;">(</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #f7981d; background-color: #ffffff;">'<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>'!D$4:D$839</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">,</span> <span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #7e3794; background-color: #ffffff;">'<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>'!$A$4:$A$839</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">,</span> <span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #11a9cc; background-color: #ffffff;">B3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span class=" string " dir="auto" style="color: green; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">"-"</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #a61d4c; background-color: #ffffff;">C3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span class=" string " dir="auto" style="color: green; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">"-*"</span><span class=" match-paren default-formula-text-color" dir="auto" style="font-weight: bold; color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #e5e5e5;">)</span></em><br />新規ユーザー数: <em><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">=</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">sumifs</span><span class=" default-formula-text-color match-paren" dir="auto" style="font-weight: bold; color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #e5e5e5;">(</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #f7981d; background-color: #ffffff;">'<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>'!E$4:E$839</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">,</span> <span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #7e3794; background-color: #ffffff;">'<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>'!$A$4:$A$839</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">,</span> <span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #11a9cc; background-color: #ffffff;">B3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span class=" string " dir="auto" style="color: green; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">"-"</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #a61d4c; background-color: #ffffff;">C3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span class=" string " dir="auto" style="color: green; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">"-*"</span><span class=" match-paren default-formula-text-color" dir="auto" style="font-weight: bold; color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #e5e5e5;">)</span></em><br />直帰数: <em><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">=</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">sumifs</span><span class=" default-formula-text-color match-paren" dir="auto" style="font-weight: bold; color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #e5e5e5;">(</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #f7981d; background-color: #ffffff;">'<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>'!F$4:F$839</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">,</span> <span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #7e3794; background-color: #ffffff;">'<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>'!$A$4:$A$839</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">,</span> <span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #11a9cc; background-color: #ffffff;">B3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span class=" string " dir="auto" style="color: green; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">"-"</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #a61d4c; background-color: #ffffff;">C3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span class=" string " dir="auto" style="color: green; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">"-*"</span><span class=" match-paren default-formula-text-color" dir="auto" style="font-weight: bold; color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #e5e5e5;">)</span></em><br />滞在時間合計: <em><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">=</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">sumifs</span><span class=" default-formula-text-color match-paren" dir="auto" style="font-weight: bold; color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #e5e5e5;">(</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #f7981d; background-color: #ffffff;">'<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>'!G$4:G$839</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">,</span> <span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #7e3794; background-color: #ffffff;">'<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>'!$A$4:$A$839</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">,</span> <span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #11a9cc; background-color: #ffffff;">B3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span class=" string " dir="auto" style="color: green; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">"-"</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #a61d4c; background-color: #ffffff;">C3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">&</span><span class=" string " dir="auto" style="color: green; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">"-*"</span><span class=" match-paren default-formula-text-color" dir="auto" style="font-weight: bold; color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #e5e5e5;">)</span></em></p>
<p>4行目以降はも同じ用に入力すると月別の合計値を出すことができます。</p>
<h4>データの計算</h4>
<p>最後に「新規ユーザー率、<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C4%BE%B5%A2%CE%A8">直帰率</a>、平均滞在時間」を計算します。</p>
<p>それぞれ取得した値を割り算するので、J〜L列3行目に以下の数式を入力してください。</p>
<p>新規ユーザー率: <em><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">=</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #f7981d; background-color: #ffffff;">G3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">/</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #7e3794; background-color: #ffffff;">F3</span></em><br /><a class="keyword" href="http://d.hatena.ne.jp/keyword/%C4%BE%B5%A2%CE%A8">直帰率</a>: <em><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">=</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #f7981d; background-color: #ffffff;">H3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">/</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #7e3794; background-color: #ffffff;">E3</span></em><br />平均滞在時間:<em> <span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">=</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #f7981d; background-color: #ffffff;">I3</span><span class=" default-formula-text-color" dir="auto" style="color: #000000; font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;">/</span><span dir="auto" style="font-family: Inconsolata, monospace, arial, sans, sans-serif; font-size: 14px; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: pre-wrap; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; color: #7e3794; background-color: #ffffff;">E3</span></em></p>
<p>作成月までのデータは取得・集計でき、それ以外は「0」「#DIV/0!」(割り算できない)となっていると思います。</p>
<p><span style="font-size: 80%;">※ 以下は2016年5月までのデータは取得でき(グレーの箇所)、それ以外はまだ取得できていないことになっています。</span></p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515131208p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515131208.png" alt="f:id:ikdtty0423:20160515131208p:plain" /></p>
<h3>データ取得の自動化</h3>
<p>このレポートですが、データ取得のために毎回【アドオン】→【<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google%20Analytics">Google Analytics</a>】→【Run reports】を実行する必要があります。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515114428p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515114428.png" alt="f:id:ikdtty0423:20160515114428p:plain" width="300px" /></p>
<p> </p>
<p>これも手間なので、上記【Run reports】の下にある【Schedule reports】から自動で取得するようにしましょう。</p>
<p>【Schedule reports】をクリックすると以下の画面が現れますので、「Enable reports to run automatically.」にチェックを入れると「Schedule reports to run ...」部分が現れます。</p>
<p>ここはそのままにして、【Save】ボタンをクリックします。</p>
<p> </p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160515115039p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160515/20160515115039.png" alt="f:id:ikdtty0423:20160515115039p:plain" /></p>
<p> </p>
<p>これで毎朝午前4時〜5時の間に自動でデータ取得を行ってくれるようになります。</p>
<p> </p>
<p>長くなりましたね...</p>
<p>ひとまず、何も修正せず、この通りにやってみてから自分に合わせて修正するのがいいかと思います。</p>
<p>次回はこの集計データを元にグラフ化を行っていきます。</p>
<h4 style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 27.2px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;">1. <a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%E2%A5%CB%A5%BF%A5%EA%A5%F3%A5%B0">モニタリング</a>レポートとは?<br /><a style="color: #8bc8e1; outline: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" href="http://31webcreation.hatenablog.com/entry/2016/05/04/115412">【Googleアナリティクス】モニタリングレポートと作成自動化の流れ</a><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/2016/05/04/115412"><br /></a></h4>
<h4 style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 27.2px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;">2. データの自動取得<br /><a style="color: #8bc8e1; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" href="http://31webcreation.hatenablog.com/entry/create-base-of-monitoring-report">【Googleアナリティクス】無料で使えるレポート作成ツールでレポートに必要なデータを取得する</a></h4>
<h4 style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 27.2px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;">3. データの集計 ← 今回</h4>
<h4 style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 27.2px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;">4. グラフ化<br /><a style="color: #8bc8e1; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" href="http://31webcreation.hatenablog.com/entry/monthly-graph-with-ga">【Googleアナリティクス API】グラフを作成する</a></h4>
<h4 style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 27.2px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;">5. 目標値の取得(CV)</h4>
<p><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/get-conversion-with-google-analytics-api">【Googleアナリティクス API】目標値(CV)の取得</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">6. 記事ごと、<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C7%A5%A3%A5%EC%A5%AF%A5%C8">ディレクト</a>リごとのデータ取得</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1; outline: 0px;" href="http://31webcreation.hatenablog.com/entry/get-page-directory-data-with-google-analytics-api">【Googleアナリティクス API】記事ごと、ディレクトリごとにデータを取得する</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">7. 流入元ごと、セグメントごとのデータ取得</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" href="http://31webcreation.hatenablog.com/entry/get-segment-with-google-analytics-api">【Googleアナリティクス API】流入元ごと、セグメントごとにデータを取得する</a></p> Wed, 18 May 2016 07:00:00 +0900
hatenablog://entry/6653812171396193752
Googleアナリティクス
-
【Googleアナリティクス】無料で使えるレポート作成ツールでレポートに必要なデータを取得する
https://31webcreation.hatenablog.com/entry/create-base-of-monitoring-report <p>では、実際に<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%E2%A5%CB%A5%BF%A5%EA%A5%F3%A5%B0">モニタリング</a>レポートを作成していきます。</p>
<p>今までのレポート作成では、<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a>アナリティクスのデータをエクセルにダウンロードして、それを集計してグラフにしてレポートを作成して...ということを毎月やっていたのではないでしょうか?</p>
<p>同じことの繰り返しだからもっとラクに出来ないかな?って思ったことはありませんか?</p>
<p>また、無料ツールを使いたいけど他社ツールだと会社の規定などによって使えなかったり使用確認が必要で面倒...という方向けに、<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a>公式のツールをご紹介します。</p>
<p>今回は基本的なデータを取得するところまでをやっていきましょう。<br /><span style="font-size: 80%;">※ 今回の内容は以下にまとめてあります。</span></p>
<p><a href="https://docs.google.com/spreadsheets/d/1ZUaU8kvaq0anYl-FkMzY01RKffj3SCTx1BSmx24ReR4/edit?usp=sharing">160516_ブログ_GAdata - Google スプレッドシート</a></p>
<h3><a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a>アナリティクス アドオンを使う</h3>
<p>アナリティクスを使うにあたって、<a class="keyword" href="http://d.hatena.ne.jp/keyword/google">google</a>用のアカウントを持っているのではないかと思います。なので、<a class="keyword" href="http://d.hatena.ne.jp/keyword/google%20drive">google drive</a> も一緒に登録してしまいましょう。</p>
<p><a href="https://www.google.com/intl/ja_jp/drive/">Google ドライブ - 写真やドキュメントなど、ファイルのクラウド ストレージとバックアップ</a></p>
<p>アカウント登録し、ログインしたら早速開始しましょう!</p>
<p> </p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160423232757p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160423/20160423232757.png" alt="f:id:ikdtty0423:20160423232757p:plain" width="150px" /></p>
<p>ドライブにログインしたら、左メニューにある【新規】ボタンをクリックし、【<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google%20%A5%B9%A5%D7%A5%EC%A5%C3%A5%C9%A5%B7%A1%BC%A5%C8">Google スプレッドシート</a>】を選択してください。</p>
<p>レポートはこの<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%B9%A5%D7%A5%EC%A5%C3%A5%C9%A5%B7%A1%BC%A5%C8">スプレッドシート</a>(<a class="keyword" href="http://d.hatena.ne.jp/keyword/google%20drive">google drive</a>上のエクセルみたいなもの)で管理していきます。</p>
<p>ファイルのタイトルは今回ブログデータを取得していくので「ブログ_GAdata」としています。目的に合わせて設定してください。</p>
<p>次にメニューにある【アドオン】をクリックし、【アドオンを取得】を選択してください。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160424091734p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160424/20160424091734.png" alt="f:id:ikdtty0423:20160424091734p:plain" /></p>
<p> </p>
<p>すると以下の画面が表示されるので、検索ボックスに「<a class="keyword" href="http://d.hatena.ne.jp/keyword/google">google</a> アナリティクス」と入力して Enter キーを押し検索をします。</p>
<p>【<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google%20Analytics">Google Analytics</a>】が表示されるので、【+ 無料】ボタンを押して追加します。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160424092136p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160424/20160424092136.png" alt="f:id:ikdtty0423:20160424092136p:plain" /></p>
<p> </p>
<p>アナリティクスのアカウントを紐付けるための確認画面が表示されますので、内容を確認し【許可】をクリックしてください。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160424093122p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160424/20160424093122.png" alt="f:id:ikdtty0423:20160424093122p:plain" /></p>
<p> </p>
<p>これで <a class="keyword" href="http://d.hatena.ne.jp/keyword/google%20%A5%B9%A5%D7%A5%EC%A5%C3%A5%C9%A5%B7%A1%BC%A5%C8">google スプレッドシート</a>からアナリティクスのデータを取得する準備が整いました。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160424093336p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160424/20160424093336.png" alt="f:id:ikdtty0423:20160424093336p:plain" /></p>
<h3>データを取得する</h3>
<p>次にデータを取得してきましょう。</p>
<p>メニューの【アドオン】→【<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google%20Analytics">Google Analytics</a>】→【Create new report】をクリックし、新しいレポートを作成します。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160424093820p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160424/20160424093820.png" alt="f:id:ikdtty0423:20160424093820p:plain" /></p>
<p> </p>
<p>クリックすると以下のように<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%B9%A5%D7%A5%EC%A5%C3%A5%C9%A5%B7%A1%BC%A5%C8">スプレッドシート</a>右側の「Create a new report」という画面が表示されるので、【Name】にはレポートの名前(今回はこの「<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>」のデータを取得するので「<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A4%CF%A4%C6%A4%CA%A5%D6%A5%ED%A5%B0">はてなブログ</a>」としています。)を記入します。</p>
<p>それ以下の【Account】【Property】【View】はお使いのアナリティクスからどのデータを取得するのか、それぞれの設定に合わせて選択してください。</p>
<p>次に、その下にある【Metrics】、【Dimensions】でPV、Sessionなど、どういったデータを取得するのかを設定していきます。(青枠)</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160424094505p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160424/20160424094505.png" alt="f:id:ikdtty0423:20160424094505p:plain" /></p>
<p> </p>
<p>まずは【Metrics】です。</p>
<p>【Metrics】をクリックすると以下の画面が現れます。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160424094748p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160424/20160424094748.png" alt="f:id:ikdtty0423:20160424094748p:plain" width="150px" /></p>
<p> </p>
<p>ここで取得するデータを指定します。</p>
<p>今回は基本的なデータ取得ということで以下のデータを選択します。</p>
<ul>
<li>Users(ユーザー数)</li>
<li>New Users(新規ユーザー数)</li>
<li>Sessions<span style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 27.2px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">(セッション数)</span></li>
<li>Bounces<span style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 27.2px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">(直帰数)</span></li>
<li>Organic Searches<span style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 27.2px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">(自然検索アクセス数)</span></li>
<li>Session Duration<span style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 27.2px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">(セッション滞在時間)</span></li>
<li>Pageviews<span style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 27.2px; orphans: auto; text-align: left; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; display: inline !important; float: none; background-color: #ffffff;">(ページビュー数)</span></li>
</ul>
<p>※ 【Metrics】をクリックした状態で「U」を入れると<a class="keyword" href="http://d.hatena.ne.jp/keyword/%B8%F5%CA%E4">候補</a>が表示されるので「Users」などと入力して<a class="keyword" href="http://d.hatena.ne.jp/keyword/%B8%F5%CA%E4">候補</a>を絞って選択してください。それ以外も同様です。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160424095048p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160424/20160424095048.png" alt="f:id:ikdtty0423:20160424095048p:plain" width="300px" /></p>
<p> </p>
<p>次に【Metrics】の下にある【Dimensions】を設定していきます。</p>
<p>レポートを作成する際、基本的には日別でのデータを集計していると思うので、今回は日別で取得していくことにします。</p>
<p>【Metrics】の場合と同様、【Dimensions】をクリックし、「date」と入力するとすぐ上に「Date」が表示されるので、こちらを選択してください。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160424095852p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160424/20160424095852.png" alt="f:id:ikdtty0423:20160424095852p:plain" width="300px" /></p>
<p> </p>
<p>入力が完成したのが以下となります。</p>
<p>完成したら「Create Report」をクリックしてレポートを作ります。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160424100215p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160424/20160424100215.png" alt="f:id:ikdtty0423:20160424100215p:plain" width="300px" /></p>
<h3><a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%B9%A5%D7%A5%EC%A5%C3%A5%C9%A5%B7%A1%BC%A5%C8">スプレッドシート</a>上の取得したデータを吐き出す</h3>
<p>「Create Report」をクリックすると「Report Configuration」というシートが作成され、先ほど入力した内容が表示されます。</p>
<p>このレポートは直近の7日間のデータを取得します。(Last N Days の部分)</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160424100621p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160424/20160424100621.png" alt="f:id:ikdtty0423:20160424100621p:plain" /></p>
<p> </p>
<p>これでデータを取得する準備が整いました。</p>
<p>最後にメニューから【アドオン】→【<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google%20Analytics">Google Analytics</a>】→【Run reports】をクリックするとアナリティクスのデータを取得できます。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160424100950p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160424/20160424100950.png" alt="f:id:ikdtty0423:20160424100950p:plain" /></p>
<p> </p>
<p>取得されるデータは以下のようになります。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160424101511p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160424/20160424101511.png" alt="f:id:ikdtty0423:20160424101511p:plain" /></p>
<p> </p>
<p>あとはこちらのデータを加工して自動でグラフを表示するなどをしていきます。</p>
<p>長かったですが、いかがでしたでしょうか?<br />次は取得する日にちを設定し、そのデータを集計していきます。</p>
<h4>1. <a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%E2%A5%CB%A5%BF%A5%EA%A5%F3%A5%B0">モニタリング</a>レポートとは?</h4>
<p><a href="http://31webcreation.hatenablog.com/entry/2016/05/04/115412">【Googleアナリティクス】モニタリングレポートと作成自動化の流れ</a></p>
<h4 style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 27.2px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;">2. データの自動取得 ← 今回</h4>
<h4 style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 27.2px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;">3. データの集計<br /><a style="color: #8bc8e1; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" href="http://31webcreation.hatenablog.com/entry/monthly-summary-with-ga">【Googleアナリティクス API】取得したデータを月別に集計する</a></h4>
<h4 style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 27.2px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;">4. グラフ化<br /><a style="color: #8bc8e1; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" href="http://31webcreation.hatenablog.com/entry/monthly-graph-with-ga">【Googleアナリティクス API】グラフを作成する</a></h4>
<h4 style="color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: 27.2px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;">5. 目標値の取得(CV)</h4>
<p><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/get-conversion-with-google-analytics-api">【Googleアナリティクス API】目標値(CV)の取得</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">6. 記事ごと、<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C7%A5%A3%A5%EC%A5%AF%A5%C8">ディレクト</a>リごとのデータ取得</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1; outline: 0px;" href="http://31webcreation.hatenablog.com/entry/get-page-directory-data-with-google-analytics-api">【Googleアナリティクス API】記事ごと、ディレクトリごとにデータを取得する</a></p>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">7. 流入元ごと、セグメントごとのデータ取得</h4>
<p style="line-height: 1.5; margin: 0.5em 0px; padding: 0px; color: #3d3f44; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px;"><a style="color: #8bc8e1; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" href="http://31webcreation.hatenablog.com/entry/get-segment-with-google-analytics-api">【Googleアナリティクス API】流入元ごと、セグメントごとにデータを取得する</a></p> Mon, 16 May 2016 07:00:00 +0900
hatenablog://entry/6653812171392654894
Googleアナリティクス
-
【Googleアナリティクス】モニタリングレポートと作成自動化の流れ
https://31webcreation.hatenablog.com/entry/2016/05/04/115412 <p>サイトやブログの運営にあたり、それぞれ目的があると思います。</p>
<p>その目的に合わせた目標(指標)を設定し、その達成度合いを見ていくのが<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%E2%A5%CB%A5%BF%A5%EA%A5%F3%A5%B0">モニタリング</a>レポートです。</p>
<h3><a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%E2%A5%CB%A5%BF%A5%EA%A5%F3%A5%B0">モニタリング</a>レポートを作成する意味</h3>
<p>目<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C9%B8%BF%F4">標数</a>値を確認していくことで、目標に対する施策の効果を測定し、改善や次の施策を検討する際の目安とすることができます。</p>
<p>また、継続して<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%E2%A5%CB%A5%BF%A5%EA%A5%F3%A5%B0">モニタリング</a>することで、月・週・日・時間などにおけるトレンドを把握できるようになります。</p>
<p>その他、数値の変化にいちはやく気づくことができ、その変化の原因や対策などを立てることも可能です。</p>
<p>最終的に施策の結果報告と施策評価にも繋がるようなレポートとなるので、これを作成しておくと改めてレポートを作成するという手間が減り、考察に時間を使うことができるようになります。</p>
<p>個人的には、チームで運営している場合、これを作ることによって全体での共通認識を作ることができ、同じ目線で施策やその結果・改善を考えることができるようになることが一番大きいかと思っています。</p>
<p> </p>
<h3>今後、本ブログでやること</h3>
<p>今回の一連の記事では、<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%E2%A5%CB%A5%BF%A5%EA%A5%F3%A5%B0">モニタリング</a>レポートのデータ取得を自動化してレポート作成の時間を減らしていくことを目的とします。</p>
<p>そのため、今回は一般的に使われるであろう PV やユーザー数、<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C4%BE%B5%A2%CE%A8">直帰率</a>などを主に扱ってレポートを作成していきます。</p>
<h3>今後の流れ</h3>
<p>今回で<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%E2%A5%CB%A5%BF%A5%EA%A5%F3%A5%B0">モニタリング</a>レポートの意味を説明しました。<br />次回以降は以下の流れで記事を書いていく予定です。</p>
<h4>2. データの自動取得</h4>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/Google%20Analytics">Google Analytics</a> <a class="keyword" href="http://d.hatena.ne.jp/keyword/API">API</a>を使ってデータの取得を行うので、その基本的な設定と実際のデータ取得を行います。<br /><br /><a style="color: #8bc8e1; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" href="http://31webcreation.hatenablog.com/entry/create-base-of-monitoring-report">【Googleアナリティクス】無料で使えるレポート作成ツールでレポートに必要なデータを取得する</a></p>
<h4>3. データの集計</h4>
<p>前回のデータ取得を応用し、日ごとのデータ取得を行います。また、月ごとにデータをまとめることを行います。<br /><br /><a style="color: #8bc8e1; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" href="http://31webcreation.hatenablog.com/entry/monthly-summary-with-ga">【Googleアナリティクス API】取得したデータを月別に集計する</a></p>
<h4>4. グラフ化</h4>
<p>前回まとめたデータをグラフ化していきます。</p>
<p>視覚化することで変化を捉えやすく、急な変化やトレンドを把握できるようになります。<br /><br /><a style="color: #8bc8e1; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" href="http://31webcreation.hatenablog.com/entry/monthly-graph-with-ga">【Googleアナリティクス API】グラフを作成する</a></p>
<h4>5. 目標値の取得(CV)</h4>
<p>サイトによって、受注やお問合せ・資料請求などのCVを設定していると思います。そのCVのデータを取得する方法をまとめます。</p>
<p><a style="color: #8bc8e1;" href="http://31webcreation.hatenablog.com/entry/get-conversion-with-google-analytics-api">【Googleアナリティクス API】目標値(CV)の取得</a></p>
<h4>6. 記事ごと、<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C7%A5%A3%A5%EC%A5%AF%A5%C8">ディレクト</a>リごとのデータ取得</h4>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;"><a style="color: #8bc8e1; outline: 0px;" href="http://31webcreation.hatenablog.com/entry/get-page-directory-data-with-google-analytics-api">【Googleアナリティクス API】記事ごと、ディレクトリごとにデータを取得する</a></h4>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;">ブログであれば記事ごとに、サイトであればURLの /***/ という形でサイトの構成がまとまっていたりすると思います。</h4>
<p>その記事ごとや /***/ ごとのデータをまとめて取得する方法を紹介します。</p>
<p><span style="font-size: 80%;">※ /***/ のことを<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C7%A5%A3%A5%EC%A5%AF%A5%C8">ディレクト</a>リごとのデータといいます。</span></p>
<h4>7. 流入元ごと、セグメントごとのデータ取得</h4>
<h4 style="clear: both; margin: 1.4em 0px 0px; font-size: 16px; padding-bottom: 0px; color: #3d3f44; line-height: 27.2px; font-style: normal; font-variant: normal; letter-spacing: normal; orphans: auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; text-align: start; background-color: #ffffff;"><a style="color: #8bc8e1; font-family: 'Helvetica Neue', Helvetica, Arial, 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', メイリオ, Meiryo, 'MS Pゴシック', 'MS PGothic', sans-serif; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 24px; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: 1; word-spacing: 0px; -webkit-text-stroke-width: 0px; background-color: #ffffff;" href="http://31webcreation.hatenablog.com/entry/get-segment-with-google-analytics-api">【Googleアナリティクス API】流入元ごと、セグメントごとにデータを取得する</a></h4>
<p>サイトの分析にあたり、流入元別のデータを取得したいケースがあると思いますので、その取得方法を紹介します。</p>
<p>また、セグメントを設定している方もいると思いますので、そのセグメントごとでデータを取得する方法もご紹介します。</p>
<p> </p>
<p>よりよい方法や間違いなどありましたら教えていただけるととても嬉しいです。</p>
<p>よろしくお願いします!</p> Wed, 04 May 2016 11:54:12 +0900
hatenablog://entry/6653812171394292194
Googleアナリティクス
-
【Rails】Wercker で mysql を使う時に出会ったエラー一覧とその対処
https://31webcreation.hatenablog.com/entry/2016/04/28/214451 <p>自分開発でCIを使おうと思って、Werckerを入れた。無料だし、プライベー<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C8%A5%EA%A5%DD%A5%B8">トリポジ</a>トリでも使えるので便利!</p>
<p>で、デフォルトの<a class="keyword" href="http://d.hatena.ne.jp/keyword/sqlite">sqlite</a>から<a class="keyword" href="http://d.hatena.ne.jp/keyword/mysql">mysql</a>に変えようと思って設定したら、いろんなところで躓いたのでそのメモを残しておこうと思う。</p>
<p>最終的に出来上がったのはこんな感じ。</p>
<p><span style="font-size: 80%;">※ 最初の <code style="font-family: monospace, serif; font-size: 1em;">MYSQL_DATABASE </code>などは config/database.yml の test の設定に合わせています。</span></p>
<pre><code>box: ruby
services:
- id: mysql
env:
MYSQL_ROOT_PASSWORD: root_password
MYSQL_USER: testuser
MYSQL_PASSWORD: testuser
MYSQL_DATABASE: testdb
build:
steps:
- script:
name: set nodejs emvironment
code: |
sudo apt-get update
sudo apt-get -y install nodejs npm
sudo update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
- script:
name: bundle - nokogiri use sys lib
code: bundle config build.nokogiri --use-system-libraries
- bundle-install
- rails-database-yml
- script:
name: DB schema load
code: bundle exec rake db:schema:load RAILS_ENV=test
- script:
name: rspec
code: bundle exec rspec</code></pre>
<p>以下、いろいろやっていく過程で出たエラーとその対処を書いていきます。</p>
<p> </p>
<h3>There was an <a class="keyword" href="http://d.hatena.ne.jp/keyword/error">error</a> while trying to load the gem 'uglifier'. (Bundler::GemRequireError)</h3>
<p>gem に therubyracer を入れるか、nodejsを使うかどちらからしい。今回はWerckerにnodejsを入れてみた。</p>
<pre><code>- script:
name: set nodejs emvironment
code: |
sudo apt-get update
sudo apt-get -y install nodejs npm
sudo update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10</code></pre>
<p> Gemfile にtherubyracerを入れるのでも大丈夫っぽい(試してないです...すみません)</p>
<pre><code>gem 'therubyracer'</code></pre>
<h3>Can't connect to local <a class="keyword" href="http://d.hatena.ne.jp/keyword/MySQL">MySQL</a> server through socket '/tmp/<a class="keyword" href="http://d.hatena.ne.jp/keyword/mysql">mysql</a>.sock' (2) (Mysql2::<a class="keyword" href="http://d.hatena.ne.jp/keyword/Error">Error</a>) </h3>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/MySQL">MySQL</a>との接続がうまく行ってないみたい。</p>
<p>config/database.yml の設定がうまく行ってない?と思ったんですが、werckerでの設定が必要みたいだったので、以下のように設定を追加しました。</p>
<pre><code>- rails-database-yml</code></pre>
<h3>Array values in the parameter to `Gem.paths=` are deprecated.Please use a String or <a class="keyword" href="http://d.hatena.ne.jp/keyword/nil">nil</a>.</h3>
<p>このエラー、よく見ると以下の2箇所が気になった。</p>
<pre><code>cannot load such file -- bundler/setup (LoadError)</code></pre>
<pre><code>Migrations are pending. To resolve this issue, run:
bin/rake db:migrate RAILS_ENV=test</code></pre>
<p>これなんだろうな??と思いつつ、2つ目のものは見慣れたエラーなので、こっちを片付けようと思って wercker上で実行する設定を追加。</p>
<pre><code>- script:
name: DB schema load
code: bundle exec rake db:schema:load</code></pre>
<h3><a class="keyword" href="http://d.hatena.ne.jp/keyword/ActiveRecord">ActiveRecord</a>::AdapterNotSpecified: 'development' database is not configured. Available: ["test"] </h3>
<p>走ってるっぽいけど、development を読み込もうとしているようなので<a class="keyword" href="http://d.hatena.ne.jp/keyword/%B4%C4%B6%AD%CA%D1%BF%F4">環境変数</a>を設定。(上記に <a class="keyword" href="http://d.hatena.ne.jp/keyword/RAILS">RAILS</a>_ENV=test を追加)</p>
<pre><code>- script:
name: DB schema load
code: bundle exec rake db:schema:load RAILS_ENV=test</code></pre>
<p>上記設定で無事 Wercker が動きました。サックリ動かせると思ったのに予想外のところでハマって時間を使った。でも勉強になった!! </p>
<p> </p>
<p>【追記 4/29】</p>
<p>今まで動いてたのに、いきなり動かなくなったりすることがある。</p>
<p>そういうときは Wercker 上でのキャッシュが悪さをしていることがあるみたい。なので、Werckerのページに行って、右上の【Settings】→【Clear Cache】で動くことがある。これでダメだったら別のことが原因。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160429092045p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160429/20160429092045.png" alt="f:id:ikdtty0423:20160429092045p:plain" /></p> Thu, 28 Apr 2016 21:44:51 +0900
hatenablog://entry/6653812171393463454
Rails
-
【Rails】capistrano でのデプロイを idobata に通知する
https://31webcreation.hatenablog.com/entry/2016/04/16/174943 <p>結構サックリいけるかなと思ったら、なぜかハマったのでメモがてら...</p>
<p>capstrano 3 だけど、</p>
<p><a href="http://qiita.com/hiro_y/items/0c5ba6ade6c2fc91e960">IdobataにCapistrano(2系)のdeploy通知を投げる - Qiita</a> この辺を参考にしつつ、とりあえずそのままベタ書きして実行してみたら怒られた。</p>
<p>config/deploy.rb</p>
<pre><code>after 'deploy:restart', 'deploy:notify_revision'
# user_name, user_repository, idobata_hook_url は自分のものに修正
namespace :deploy do
# idobata 通知
task :notify_revision do
user_name = `git config --global user.name`.gsub("
", '')
github_path = "https://github.com/user_name/user_repository/tree/#{current_revision}"
source = "App was deployed by #{user_name} <span class=""label">#{stage}deployed source tree: <a href=""#{github_path}"" target=""_blank"">#{current_revision[0, 7]}"
idobata_hook_url = "https://idobata.io/hook/custom/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
run "curl --data-urlencode 'source=#{source}' -d format=html #{idobata_hook_url}"
end
end</a></span></code></pre>
<pre><code>cap aborted!
Don't know how to build task 'deploy:notify_revision' (see --tasks)</code></pre>
<p>ゴニョゴニョしたけどなぜかタスクが読み取られず... </p>
<p> </p>
<h3>タスクを分けて実行</h3>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/capistrano">capistrano</a> のタスクは `lib/<a class="keyword" href="http://d.hatena.ne.jp/keyword/capistrano">capistrano</a>/tasks/idobata_notify_revision.cap` に切り出して実行してみた。</p>
<p>config/deploy.rb</p>
<pre><code># 上で追加した奴は全部削除して...
after 'deploy:restart', 'idobata:notify'</code></pre>
<p>lib/<a class="keyword" href="http://d.hatena.ne.jp/keyword/capistrano">capistrano</a>/tasks/idobata_notify_revision.cap を新規作成。</p>
<pre><code># user_name, user_repository, idobata_hook_url は自分のものに修正
namespace :idobata do
task :notify do
user_name = `git config --global user.name`.gsub("
", '')
current_revision = "`cat #{current_path}/current`"
github_path = "https://github.com/user_name/user_repository/tree/#{fetch(:branch)}"
source = "App was deployed by #{user_name} <span class=""label">#{fetch(:rails_env)}deployed source tree: <a href=""#{github_path}"" target=""_blank"">#{fetch(:branch)}"
idobata_hook_url = "https://idobata.io/hook/custom/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
on roles :all do
execute "curl --data-urlencode 'source=#{source}' -d format=html #{idobata_hook_url}"
end
end
end</a></span></code></pre>
<p>最初、ファイル名を `.rake` で作成しても読み取られず、いろいろ見てたら Capfile に .cap の指定をしてました...</p>
<pre><code>Dir.glob('lib/capistrano/tasks/*.cap').each { |r| import r }</code></pre>
<p>はい、ごめんなさい...</p>
<p>あと、run じゃねーよ(NoMethodError: undefined method `run' for main:Object)!</p>
<p>とか、execute だけだと動かなかったりして on roles :all do ... end で囲ったりして上記で大丈夫そうでした!</p>
<h3>おまけ</h3>
<p>デプロイタスクをテストするのに、毎回デプロイするのダルいな...って思ってたら、そのタスクだけ実行できた。上記の場合だと...</p>
<pre><code>cap production idobata:notify</code></pre>
<p> って指定するとそのタスクを実行してくれる。はい、知りませんでした...</p>
<p>ってことで、デプロイタスクもいろいろ作っていこうと思います。</p>
<p> </p> Sat, 16 Apr 2016 17:49:43 +0900
hatenablog://entry/10328537792371373674
Rails
-
【Rails】CSSのベンダープレフィックスをいい感じに自動で付けてくれる gem 'autoprefixer-rails'
https://31webcreation.hatenablog.com/entry/2016/04/16/171858 <p>最近<a class="keyword" href="http://d.hatena.ne.jp/keyword/CSS">CSS</a>でできることの幅が増えてきた。また、flexbox などの<a class="keyword" href="http://d.hatena.ne.jp/keyword/CSS">CSS</a>レイアウトも使う機会が増えてきていると思います。</p>
<p>使うときに毎回ベンタープレフィックスを気にしていられないし、だからといって付け忘れるとレイアウトが崩れる...</p>
<p>そんな悩みは<a class="keyword" href="http://d.hatena.ne.jp/keyword/Rails">Rails</a>のgem 'autoprefixer-<a class="keyword" href="http://d.hatena.ne.jp/keyword/rails">rails</a>'で一発解消!</p>
<p> </p>
<h3>autoprefixer-<a class="keyword" href="http://d.hatena.ne.jp/keyword/rails">rails</a> の使い方</h3>
<p>Gemfileに以下を記載して、 bundle install これだけ!</p>
<pre><code>gem 'autoprefixer-rails'</code></pre>
<p> あとは<a class="keyword" href="http://d.hatena.ne.jp/keyword/CSS">CSS</a>にベンダープレフィックスを除いたものを一つだけ書けがいい感じで補完してくれます。</p>
<p>例えば...グラデーションは以下の様な感じで細々書いていたと思います。</p>
<pre><code>.gradient {
background: -webkit-linear-gradient(top, #999, #067);
background: linear-gradient(top, #999, #067);
}</code></pre>
<p>でも、autoprefixer-<a class="keyword" href="http://d.hatena.ne.jp/keyword/rails">rails</a> を入れているので以下の様な感じで1つだけでOK!</p>
<pre><code>.gradient {
background: linear-gradient(top, #999, #067);
}</code></pre>
<p> 表示される<a class="keyword" href="http://d.hatena.ne.jp/keyword/CSS">CSS</a>を見てみるといい感じで補完してくれてます!</p>
<p><img class="hatena-fotolife" style="border: solid 1px #ccc;" title="f:id:ikdtty0423:20160416171358p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160416/20160416171358.png" alt="f:id:ikdtty0423:20160416171358p:plain" /></p>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/Rails">Rails</a> を使っているとこういう細かいところへの配慮をいい感じで処理してくれるのはとても助かります!</p>
<h3>flexbox もいけるっぽい</h3>
<p>flexbox も使ってみんですが、これもいい感じで補完してくれます。</p>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/CSS">CSS</a>には以下を記載しただけです。</p>
<pre><code> .flexbox {
display: flex;
justify-content: center;
flex-wrap: wrap;
}</code></pre>
<p> するとどうでしょう(笑)こんな感じになってます。</p>
<pre><code>.flexbox {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-box-pack: center;
-webkit-justify-content: center;
-ms-flex-pack: center;
justify-content: center;
-webkit-flex-wrap: wrap;
-ms-flex-wrap: wrap;
flex-wrap: wrap;
}</code></pre>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/CSS">CSS</a>だけかな?って思ってたんですが、flexboxのような<a class="keyword" href="http://d.hatena.ne.jp/keyword/CSS">CSS</a>レイアウトにも対応してくれるのはとても嬉しいですね!</p>
<p>ぜひ、使ってみてください! </p> Sat, 16 Apr 2016 17:18:58 +0900
hatenablog://entry/10328537792371370561
Rails
-
【Google アナリティクス】訪問してきた会社がどのページを見ているか確認する方法
https://31webcreation.hatenablog.com/entry/2016/04/04/073739 <p>前回、<a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a> アナリティクスでサイトに訪問してきた会社・企業を確認する方法を見ました(↓↓)。</p>
<p><iframe class="embed-card embed-blogcard" style="display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;" title="【Google アナリティクス】サイトに訪問した会社を確認する方法 - 31歳から始めたプログラマーという仕事" src="http://31webcreation.hatenablog.com/embed/2016/04/02/220457" frameborder="0" scrolling="no"></iframe></p>
<p> </p>
<p>今回はその企業の人がどのページを見たのかを確認する方法を紹介します。</p>
<p> </p>
<h3>見たい会社・企業URLをピックアップ</h3>
<p>上に載せた前回の記事の方法で、サイトに訪問している会社・企業を確認します。</p>
<p>サイトに来ている会社・企業のURLが出てくるので、見たい会社・企業のURLをメモしておきます。(【ネットワーク<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C9%A5%E1%A5%A4%A5%F3">ドメイン</a>】欄に表示されるURLです)</p>
<h3>訪問会社・企業の見たページを確認する</h3>
<p>まず、左メニューの【行動 > サイトコンテンツ > すべてのページ】をクリックします。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160402222700p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160402/20160402222700.png" alt="f:id:ikdtty0423:20160402222700p:plain" width="200px" /></p>
<p> </p>
<p>表示が切り替わったら、前回の記事と同様にページ真ん中の【セカンダリディメンション】から虫眼鏡マークの欄に「ネットワーク」をいれ、下に表示される【ネットワーク<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C9%A5%E1%A5%A4%A5%F3">ドメイン</a>】を選択してください。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160402224506p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160402/20160402224506.png" alt="f:id:ikdtty0423:20160402224506p:plain" width="250" /></p>
<p> </p>
<p>そして、その右にある【アドバンス】をクリックします。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160402220335p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160402/20160402220335.png" alt="f:id:ikdtty0423:20160402220335p:plain" /></p>
<p> </p>
<p>クリックすると以下の画面が表示されるので、緑色の箇所をクリックし、【ネットワーク<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C9%A5%E1%A5%A4%A5%F3">ドメイン</a>】を選択、右隣は【完全一致】、その右の入力欄は、先ほどメモしておいたURL(***.com または *** .co.jp)を入力し、左下の【適用】をクリックします。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160402225419p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160402/20160402225419.png" alt="f:id:ikdtty0423:20160402225419p:plain" /></p>
<p> </p>
<p>するとどうでしょう(笑)</p>
<p>指定したURLから来た会社の人がどのページを見たのかが表示されます!あとは、どのページを見ているのか、滞在時間はどのくらいか?<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C4%BE%B5%A2%CE%A8">直帰率</a>は?などの情報を見ていくことができます。</p>
<p>前回の記事から繋がる内容でしたがいかがでしょうか?</p>
<p>営業への情報提供として、かなり使える情報になってくるかと思います!ぜひお試しください!</p> Mon, 04 Apr 2016 07:37:39 +0900
hatenablog://entry/10328537792369545754
-
【Google アナリティクス】サイトに訪問した会社を確認する方法
https://31webcreation.hatenablog.com/entry/2016/04/02/220457 <p>最近アナリティクスをいじっていることが多いんですが、営業の人に喜ばれたデータが「サイトに訪問している会社・企業」情報です。</p>
<p>これ、僕も知らなかったんですが見ていても面白いので確認してみてください!</p>
<p> </p>
<h3><a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a> アナリティクスでサイトに訪問した会社・企業を確認する</h3>
<p>左メニューから【ユーザー > ユーザー環境 > ネットワーク】を選択します。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160402211911p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160402/20160402211911.png" alt="f:id:ikdtty0423:20160402211911p:plain" width="200px" /></p>
<p> </p>
<p>表示が切り替わったらページの真ん中あたりにある【セカンダリディメンション】をクリック。虫眼鏡マークに【ネットワーク】と入力するとその下に【ネットワーク<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C9%A5%E1%A5%A4%A5%F3">ドメイン</a>】という表示が出るので選択します。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160402212159p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160402/20160402212159.png" alt="f:id:ikdtty0423:20160402212159p:plain" width="400px" /></p>
<p> </p>
<p>するとすぐ下の表に【ネットワーク<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C9%A5%E1%A5%A4%A5%F3">ドメイン</a>】が表示されます。</p>
<p>これで【ネットワーク<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C9%A5%E1%A5%A4%A5%F3">ドメイン</a>】の箇所に訪問してきた人のURLが表示されます。</p>
<p>※ あまりアナリティクスの画面数値を表示するとダメらしいので、一番上だけ表示しています。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160402212641p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160402/20160402212641.png" alt="f:id:ikdtty0423:20160402212641p:plain" width="400px" /></p>
<p> </p>
<h3>会社・企業URLのみに絞込</h3>
<p>ただ、この表示だと会社・企業のURL以外のものも入っているのでこれを絞込します。</p>
<p>方法は先ほど【セカンダリディメンション】を指定したところの右側【アドバンス】をクリックします。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160402220335p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160402/20160402220335.png" alt="f:id:ikdtty0423:20160402220335p:plain" /></p>
<p> </p>
<p>すると以下の表示が現れるので、緑色のところをクリックして【ネットワーク<a class="keyword" href="http://d.hatena.ne.jp/keyword/%A5%C9%A5%E1%A5%A4%A5%F3">ドメイン</a>】をクリック。</p>
<p>すぐ右の欄をクリックして【<a class="keyword" href="http://d.hatena.ne.jp/keyword/%C0%B5%B5%AC%C9%BD%B8%BD">正規表現</a>一致】をクリック。</p>
<p>その右の欄に【\.com|\.co\.jp】を入力し、左下の【適用】をクリックします。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160402213953p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160402/20160402213953.png" alt="f:id:ikdtty0423:20160402213953p:plain" /></p>
<p> </p>
<p>するとどうでしょう(笑)</p>
<p>訪問してきた人のうち、【.com】【.co.jp】の人に絞りこまれた一覧を見ることができます。</p>
<p>※ 以下の画像は一番上のものだけ表示しています。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160402215203p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160402/20160402215203.png" alt="f:id:ikdtty0423:20160402215203p:plain" width="300px" /></p>
<h3>データの共有方法</h3>
<p>あとはデータの共有ですが、アナリティクスのアカウントを持っているならブラウザのURLをコピペして共有すれば大丈夫です!</p>
<p>アカウントを持っていない場合は、この表示のままページの一番上にある【エクスポート】をクリックすると以下の画面が現れるので、好きな形式でダウンロードしてください。</p>
<p><img class="hatena-fotolife" title="f:id:ikdtty0423:20160402215608p:plain" src="http://cdn-ak.f.st-hatena.com/images/fotolife/i/ikdtty0423/20160402/20160402215608.png" alt="f:id:ikdtty0423:20160402215608p:plain" width="250px" /></p>
<p> </p>
<p>以上、サイトに訪問してきた企業のURLを見る方法でした!</p>
<p><a class="keyword" href="http://d.hatena.ne.jp/keyword/Google">Google</a> アナリティクスからこんな情報を取れるって知らなかったんですが、どんな企業が自社サイトに興味を持っているのかを確認するのにとても役立つのでぜひやってみてください!</p>
<p> </p>
<p>※ 上記データはこのブログのデータです。</p>
<p> </p>
<p>【追記】<a class="keyword" href="http://d.hatena.ne.jp/keyword/CSV">CSV</a>やエクセルにデータを吐き出す場合、企業URLをクリックしてもブラウザにサイトが表示されない場合があります。</p>
<p>その場合は、URLの最初に【www】を追加してみてください。殆どの場合、これで見れます。</p>
<p>ex)【hakuhodo.co.jp】の場合、【www.hakuhodo.co.jp】とすることで見ることができます。</p>
<p>URLを作るときの慣習(?)なのか、【www.】を付ける企業が多いようです。</p> Sat, 02 Apr 2016 22:04:57 +0900
hatenablog://entry/10328537792369537992
Googleアナリティクス