If the page has id="ga", google analytics with gtag will not receive sessions.

If the page has id="ga", google analytics with gtag will not receive sessions.

本篇中文版:如果頁面有id=”ga”,用gtag埋google analytics會收不到流量

First, let’s start with the conclusion:
If the html of the page has id="ga", and the way to set the Google Analytics code is gtag, then GA will not receive the pageview.

This article is the process from finding a problem to finding a problem and finally solving the problem.

Because I haven’t found an article on the Internet: “because the page has id=”ga”, I can’t receive sessions”, so I wrote this, hope that the webpage that can be avoided, or the same problem can solve this problem.


The Problem Found

This is a bitter experience in the past few days. After writing the following two articles:

In the beginning, I wanted to compare the difference between Chinese and English article traffic, but one day passed and two days passed. The traffic of these two articles traffic has been zero.

The strange thing is that when I look at hotjar, I see someone coming into Chinese article to watch it. Fb sharing also has friends to click like, how can anyone come in and read? But GA has never received data.

I enter other articles, and other articles can receive traffic, but these two can not.

Then I opened the GA Debugger and started the process of finding bugs.


Find The Problem

In the beginning, I suspected that I didn’t receive sessions because I installed the Chrome extension that prohibits ga tracking. “Google Analytics Opt-out Add-on“. After the removal, the Realtime report still did not see the pageviews.

Then I thought that the day before I write the article, I wanted to try AB/test. When I setting the GA tracking code, I added the config of google optimize, and went to optimize to end the A/B test, but the same, the GA page view did not send out.

Then I thought, is it that my custom dimension code is wrong? Then the use of my custom dimension(Chinese) article does not have to be rewritten?

Fortunately, even if I delete the custom dimension code, I did not receive traffic.

Then I tried to delete the GA event tracking, service-worker.js, and Mixpanel, and I didn’t solve the problem that GA couldn’t receive the pageview.

Finally, I had to take the most stupid way to download the page into a static html file, delete it line by line, and see which line to delete the GA.


Generally looking for front-end bugs, the first one to find is javascript, because js is most likely to block ajax.

First delete the js referenced on the page and the <script> written directly. If you find that the traffic comes in, find out which file is causing it.

Result: After the deletion, the traffic is still not received.

Does css affect? Under the doubt, it is deleted, and the referenced <style> on the page is deleted.

Result: sessions were not received

I have to look at the other html parts, first delete the <head>, it does not work.

Then delete the entire <body>, well, Ga received traffic!

That’s for sure, it’s a problem with the front-end page, not a GA setting or a server problem.

Html line by line, delete this line:

<h3>
  <span class="ez-toc-section" id="ga" tabindex="-1">ga</span>
</h3>

GA can receive traffic and finally find the problem. This line of questions will be related to GA is id="ga".

But I am also confused, why do I write the line id="ga"? I feel this id will be a reserved word for google analytics.

After reading the page, I found out that in order to make the page add internal links, and to make it easier for everyone to read, I have installed the “Easy Table of Contents” plugin. The id is automatically generated by this plugin. It will catch the English in the title. Automatically turn English into the id of this title. As a result, both of my articles have a title called “ga”.


Solve The Problem

In the beginning, the text of the title is first falsified. If the original title is “ga”, it will be changed to “ga code”, so that the id generated by the plugin becomes ga-code.

This is fine in English, but there is a problem in Chinese, that is, Easy Table of Contents only catches the English id in the title, and my Chinese article has a title of “What are the benefits of learning GA Event?”. The plug-in only catches the “ga” out, so I have to change the title to “the benefit of setting the GA Event.”


Say again why the GA traffic is zero?

This is very important. This is the experience of real people and non-adapted tragedies, so I will explain them at the end:

If the webpage’s html, id="ga" appears, and the way to setting Google Analytics is gtag, then GA will not receive the pageviews.

If you find this article helpful, please click on the helpful button made by myself. If you are willing to share on the social, that’s even better.

Summary
If the page has id="ga", google analytics with gtag will not receive sessions.
Article Name
If the page has id="ga", google analytics with gtag will not receive sessions.
Description
If the html of the page has id="ga", and the way to set the Google Analytics code is gtag, then GA will not receive the pageview.
Author
Publisher Name
Let's Write
Publisher Logo

Leave a Reply

Your email address will not be published. Required fields are marked *