LoginSignup
1
1

More than 5 years have passed since last update.

GAのヒット数がある日0になった話

Last updated at Posted at 2018-03-19

今回は、GAのお話し。
ショボいPVながらも、きまぐれ更新していた自身のまとめサイトのGAヒット数が急にゼロに。

おいおい。勘弁してくれということで、下記対応をしてみました。

スペック

CMS:WordPress 4.9.4 (自動更新)
テーマ:Simplicity2
GAのタグはanalytics.jsタグを使用
インストールしてある主要プラグインは下記
・AddToAny Share Buttons (シェアボタン)
・Akismet Anti-Spam (アンチスパム)
・All In One SEO Pack など

やったこと①TagAssistantのインストール

Chromeの拡張機能”TagAssistant”をインストールし、調査。

【参考ページ】
Tag Assistant Recording」を利用して、Google アナリティクスが正しく実装されているかを実際に画面遷移してチェック!/Kobitブログ

結果は、

Add Google Analytics
We have detected that there is no Google Analytics tracking code found on this page.
Failing to have Google Analytics tracking code on this page will prevent data from this particular page from associating to your Analytics account.
Solution: Ensure that you add the Google Analytics tracking code onto this page before the closing tag.

なんというか、そもそも入って無いよと。
いやいや、昨日まで動いてたんだって。

やっとこと②wordpress&プラグインの更新

調べたところ、下記も怪しい。

  • wordpressのバージョン
  • 非正規プラグインの互換

wordpressは自動更新だから良いとして、プラグインをチェックしてみる。
そうだ。All in ONE SEOでトラッキングID設定したんだった。
とりあえず、有効無効関係なく全部更新。

やったこと③トラッキングコードの実装確認

横着して確認しなかったChromeの検証でheadタグ内を確認。

参考
トラッキングコードの確認と設置/Admin Web


headタグには入っている。
閉じタグの直前でなきゃいけなかったっけ?

やったこと④analytics.js→gtag.jsへ変更

プラグインからanalytics.jsを削除し、headタグに改めて追記。

header.php
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxxx-x"></script>

<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-xxxxxxxx-x');
</script>

wordpressなので、全ページに反映されます。

TagAssistantで確認。
スクリーンショット 2018-03-19 20.29.37.png

gtagは反応した!
そんでもって、自身のスマホ別ブラウザでアクセスして、 レポート => リアルタイムをチェックしてみると、
スクリーンショット 2018-03-19 20.37.16.png

キター!
めでたしめでたし。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1