Google Analytics stopped gathering data when migrated to gtag.js












0














I have an angular.js webapp and I´m using Google Analytics. On 16/11 I migrated my angular webapp from the old universal google-analytics.js script to the new gtag.js. Next day, I stopped to getting analytics information. See the screenshot.
enter image description here



Some considerations:




  1. I just migrated the js in the webapp.

  2. I didn´t change any configuration in Google Analytics.

  3. With the purpose to filter spam or ghost visits in GA, since a long time ago I had a filter that I "expected" to allow analytics only from my site, like:
    enter image description here


  4. I have another view without any filter that I have noticed that seems to work. So for some reason the root cause could be the filter.


  5. Also, I have noticed the real-time reports are not working in the filtered view, however, they are working in the not filtered view.

  6. For testing purposes, I have just deleted the filter and the real-time reports are working.


As before the migration, I was gathering analytics, I think there are maybe different problems:
- It looks like the filter is (and was before the migration) preventing the real-time reports to work.
- Apart from the real-time reports, the analytics were working before the migration with the filter, so is there anything that needs to be changed, updated in analytics in order the gtag.js works. Or maybe gtag.js is working in a different way that makes analytics not work with that filter?
- Should I delete the filter in any case? At the moment, I have deleted it and I will observe what happens with the analytics next days. However, if I delete the filter the spam analytics will come back. Maybe there is another filter that has to be applied.



UPDATE:
I attach the Gtag.js script in the website:



<script async src="https://www.googletagmanager.com/gtag/js?id=UA-property-1"></script>
<script>
var gaEnv;
switch (window.location.hostname) {
case 'www.domain.com':
gaEnv = 'UA-property-1'; // production
break;
case 'www.test.domain.com':
gaEnv = 'UA-property-3'; // test
break;
default:
gaEnv = 'UA-property-2'; // development
}
window.dataLayer = window.dataLayer || ;
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
// Config for analytics
gtag('config', gaEnv, { 'send_page_view': false });
// Config for Adwords
gtag('config', 'AW-property');
</script>


As I use Angularjs I hace developed a service to track page views, like:



service.trackPageView = function (url) {      
gtag('config', trackingId, {'page_location': url});
/* Old code for google-analytics.js. deprecated with gtag.js
* ga('set', 'page', url);
* ga('send', 'pageview', url); */
};


UPDATE 2: I have installed Google Tag Assistant. It looks like it´s gathering the data and tracking the pageviews. The only strange thing that I see is the alert: This hit is missing the hostname in the URI.



UPDATE 3: As I suspected, when I delete the "include only" my hostname filter in the analytics view, the data is gathered again as you can see in the pic.



enter image description here



So, it´s pretty clear that gtag.js is sendind data from the app to Analytics to the right property.



Now, the only point is that I had that filter that I have deleted to filter the ghost analytics spam. So, I assume it will be back soon. Again to the starting point.
My concern is if it´s maybe related to the info that I send to analytics or maybe the filter was wrong. So, I think I will need help to setup the filter working properly with this gtag.js library.










share|improve this question
























  • Can you provide some details on the changes you've made to your app? Provide some examples of where you've implemented the gtag.js code on page and examples of where you're sending data to GA via the gtag.js functions.
    – XTOTHEL
    Nov 23 '18 at 18:08










  • Please, see my updates.
    – Rober
    Nov 23 '18 at 19:45










  • For your error, can you provide an example of what “url” looks like when you pass it into function? I suspect that might be the issue.
    – XTOTHEL
    Nov 23 '18 at 20:22










  • Please, see my new UPDATE3. Maybe you get new conclusions.
    – Rober
    Nov 24 '18 at 7:45
















0














I have an angular.js webapp and I´m using Google Analytics. On 16/11 I migrated my angular webapp from the old universal google-analytics.js script to the new gtag.js. Next day, I stopped to getting analytics information. See the screenshot.
enter image description here



Some considerations:




  1. I just migrated the js in the webapp.

  2. I didn´t change any configuration in Google Analytics.

  3. With the purpose to filter spam or ghost visits in GA, since a long time ago I had a filter that I "expected" to allow analytics only from my site, like:
    enter image description here


  4. I have another view without any filter that I have noticed that seems to work. So for some reason the root cause could be the filter.


  5. Also, I have noticed the real-time reports are not working in the filtered view, however, they are working in the not filtered view.

  6. For testing purposes, I have just deleted the filter and the real-time reports are working.


As before the migration, I was gathering analytics, I think there are maybe different problems:
- It looks like the filter is (and was before the migration) preventing the real-time reports to work.
- Apart from the real-time reports, the analytics were working before the migration with the filter, so is there anything that needs to be changed, updated in analytics in order the gtag.js works. Or maybe gtag.js is working in a different way that makes analytics not work with that filter?
- Should I delete the filter in any case? At the moment, I have deleted it and I will observe what happens with the analytics next days. However, if I delete the filter the spam analytics will come back. Maybe there is another filter that has to be applied.



UPDATE:
I attach the Gtag.js script in the website:



<script async src="https://www.googletagmanager.com/gtag/js?id=UA-property-1"></script>
<script>
var gaEnv;
switch (window.location.hostname) {
case 'www.domain.com':
gaEnv = 'UA-property-1'; // production
break;
case 'www.test.domain.com':
gaEnv = 'UA-property-3'; // test
break;
default:
gaEnv = 'UA-property-2'; // development
}
window.dataLayer = window.dataLayer || ;
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
// Config for analytics
gtag('config', gaEnv, { 'send_page_view': false });
// Config for Adwords
gtag('config', 'AW-property');
</script>


As I use Angularjs I hace developed a service to track page views, like:



service.trackPageView = function (url) {      
gtag('config', trackingId, {'page_location': url});
/* Old code for google-analytics.js. deprecated with gtag.js
* ga('set', 'page', url);
* ga('send', 'pageview', url); */
};


UPDATE 2: I have installed Google Tag Assistant. It looks like it´s gathering the data and tracking the pageviews. The only strange thing that I see is the alert: This hit is missing the hostname in the URI.



UPDATE 3: As I suspected, when I delete the "include only" my hostname filter in the analytics view, the data is gathered again as you can see in the pic.



enter image description here



So, it´s pretty clear that gtag.js is sendind data from the app to Analytics to the right property.



Now, the only point is that I had that filter that I have deleted to filter the ghost analytics spam. So, I assume it will be back soon. Again to the starting point.
My concern is if it´s maybe related to the info that I send to analytics or maybe the filter was wrong. So, I think I will need help to setup the filter working properly with this gtag.js library.










share|improve this question
























  • Can you provide some details on the changes you've made to your app? Provide some examples of where you've implemented the gtag.js code on page and examples of where you're sending data to GA via the gtag.js functions.
    – XTOTHEL
    Nov 23 '18 at 18:08










  • Please, see my updates.
    – Rober
    Nov 23 '18 at 19:45










  • For your error, can you provide an example of what “url” looks like when you pass it into function? I suspect that might be the issue.
    – XTOTHEL
    Nov 23 '18 at 20:22










  • Please, see my new UPDATE3. Maybe you get new conclusions.
    – Rober
    Nov 24 '18 at 7:45














0












0








0







I have an angular.js webapp and I´m using Google Analytics. On 16/11 I migrated my angular webapp from the old universal google-analytics.js script to the new gtag.js. Next day, I stopped to getting analytics information. See the screenshot.
enter image description here



Some considerations:




  1. I just migrated the js in the webapp.

  2. I didn´t change any configuration in Google Analytics.

  3. With the purpose to filter spam or ghost visits in GA, since a long time ago I had a filter that I "expected" to allow analytics only from my site, like:
    enter image description here


  4. I have another view without any filter that I have noticed that seems to work. So for some reason the root cause could be the filter.


  5. Also, I have noticed the real-time reports are not working in the filtered view, however, they are working in the not filtered view.

  6. For testing purposes, I have just deleted the filter and the real-time reports are working.


As before the migration, I was gathering analytics, I think there are maybe different problems:
- It looks like the filter is (and was before the migration) preventing the real-time reports to work.
- Apart from the real-time reports, the analytics were working before the migration with the filter, so is there anything that needs to be changed, updated in analytics in order the gtag.js works. Or maybe gtag.js is working in a different way that makes analytics not work with that filter?
- Should I delete the filter in any case? At the moment, I have deleted it and I will observe what happens with the analytics next days. However, if I delete the filter the spam analytics will come back. Maybe there is another filter that has to be applied.



UPDATE:
I attach the Gtag.js script in the website:



<script async src="https://www.googletagmanager.com/gtag/js?id=UA-property-1"></script>
<script>
var gaEnv;
switch (window.location.hostname) {
case 'www.domain.com':
gaEnv = 'UA-property-1'; // production
break;
case 'www.test.domain.com':
gaEnv = 'UA-property-3'; // test
break;
default:
gaEnv = 'UA-property-2'; // development
}
window.dataLayer = window.dataLayer || ;
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
// Config for analytics
gtag('config', gaEnv, { 'send_page_view': false });
// Config for Adwords
gtag('config', 'AW-property');
</script>


As I use Angularjs I hace developed a service to track page views, like:



service.trackPageView = function (url) {      
gtag('config', trackingId, {'page_location': url});
/* Old code for google-analytics.js. deprecated with gtag.js
* ga('set', 'page', url);
* ga('send', 'pageview', url); */
};


UPDATE 2: I have installed Google Tag Assistant. It looks like it´s gathering the data and tracking the pageviews. The only strange thing that I see is the alert: This hit is missing the hostname in the URI.



UPDATE 3: As I suspected, when I delete the "include only" my hostname filter in the analytics view, the data is gathered again as you can see in the pic.



enter image description here



So, it´s pretty clear that gtag.js is sendind data from the app to Analytics to the right property.



Now, the only point is that I had that filter that I have deleted to filter the ghost analytics spam. So, I assume it will be back soon. Again to the starting point.
My concern is if it´s maybe related to the info that I send to analytics or maybe the filter was wrong. So, I think I will need help to setup the filter working properly with this gtag.js library.










share|improve this question















I have an angular.js webapp and I´m using Google Analytics. On 16/11 I migrated my angular webapp from the old universal google-analytics.js script to the new gtag.js. Next day, I stopped to getting analytics information. See the screenshot.
enter image description here



Some considerations:




  1. I just migrated the js in the webapp.

  2. I didn´t change any configuration in Google Analytics.

  3. With the purpose to filter spam or ghost visits in GA, since a long time ago I had a filter that I "expected" to allow analytics only from my site, like:
    enter image description here


  4. I have another view without any filter that I have noticed that seems to work. So for some reason the root cause could be the filter.


  5. Also, I have noticed the real-time reports are not working in the filtered view, however, they are working in the not filtered view.

  6. For testing purposes, I have just deleted the filter and the real-time reports are working.


As before the migration, I was gathering analytics, I think there are maybe different problems:
- It looks like the filter is (and was before the migration) preventing the real-time reports to work.
- Apart from the real-time reports, the analytics were working before the migration with the filter, so is there anything that needs to be changed, updated in analytics in order the gtag.js works. Or maybe gtag.js is working in a different way that makes analytics not work with that filter?
- Should I delete the filter in any case? At the moment, I have deleted it and I will observe what happens with the analytics next days. However, if I delete the filter the spam analytics will come back. Maybe there is another filter that has to be applied.



UPDATE:
I attach the Gtag.js script in the website:



<script async src="https://www.googletagmanager.com/gtag/js?id=UA-property-1"></script>
<script>
var gaEnv;
switch (window.location.hostname) {
case 'www.domain.com':
gaEnv = 'UA-property-1'; // production
break;
case 'www.test.domain.com':
gaEnv = 'UA-property-3'; // test
break;
default:
gaEnv = 'UA-property-2'; // development
}
window.dataLayer = window.dataLayer || ;
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
// Config for analytics
gtag('config', gaEnv, { 'send_page_view': false });
// Config for Adwords
gtag('config', 'AW-property');
</script>


As I use Angularjs I hace developed a service to track page views, like:



service.trackPageView = function (url) {      
gtag('config', trackingId, {'page_location': url});
/* Old code for google-analytics.js. deprecated with gtag.js
* ga('set', 'page', url);
* ga('send', 'pageview', url); */
};


UPDATE 2: I have installed Google Tag Assistant. It looks like it´s gathering the data and tracking the pageviews. The only strange thing that I see is the alert: This hit is missing the hostname in the URI.



UPDATE 3: As I suspected, when I delete the "include only" my hostname filter in the analytics view, the data is gathered again as you can see in the pic.



enter image description here



So, it´s pretty clear that gtag.js is sendind data from the app to Analytics to the right property.



Now, the only point is that I had that filter that I have deleted to filter the ghost analytics spam. So, I assume it will be back soon. Again to the starting point.
My concern is if it´s maybe related to the info that I send to analytics or maybe the filter was wrong. So, I think I will need help to setup the filter working properly with this gtag.js library.







google-analytics gtag.js






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 '18 at 7:45







Rober

















asked Nov 23 '18 at 12:33









RoberRober

2,704103778




2,704103778












  • Can you provide some details on the changes you've made to your app? Provide some examples of where you've implemented the gtag.js code on page and examples of where you're sending data to GA via the gtag.js functions.
    – XTOTHEL
    Nov 23 '18 at 18:08










  • Please, see my updates.
    – Rober
    Nov 23 '18 at 19:45










  • For your error, can you provide an example of what “url” looks like when you pass it into function? I suspect that might be the issue.
    – XTOTHEL
    Nov 23 '18 at 20:22










  • Please, see my new UPDATE3. Maybe you get new conclusions.
    – Rober
    Nov 24 '18 at 7:45


















  • Can you provide some details on the changes you've made to your app? Provide some examples of where you've implemented the gtag.js code on page and examples of where you're sending data to GA via the gtag.js functions.
    – XTOTHEL
    Nov 23 '18 at 18:08










  • Please, see my updates.
    – Rober
    Nov 23 '18 at 19:45










  • For your error, can you provide an example of what “url” looks like when you pass it into function? I suspect that might be the issue.
    – XTOTHEL
    Nov 23 '18 at 20:22










  • Please, see my new UPDATE3. Maybe you get new conclusions.
    – Rober
    Nov 24 '18 at 7:45
















Can you provide some details on the changes you've made to your app? Provide some examples of where you've implemented the gtag.js code on page and examples of where you're sending data to GA via the gtag.js functions.
– XTOTHEL
Nov 23 '18 at 18:08




Can you provide some details on the changes you've made to your app? Provide some examples of where you've implemented the gtag.js code on page and examples of where you're sending data to GA via the gtag.js functions.
– XTOTHEL
Nov 23 '18 at 18:08












Please, see my updates.
– Rober
Nov 23 '18 at 19:45




Please, see my updates.
– Rober
Nov 23 '18 at 19:45












For your error, can you provide an example of what “url” looks like when you pass it into function? I suspect that might be the issue.
– XTOTHEL
Nov 23 '18 at 20:22




For your error, can you provide an example of what “url” looks like when you pass it into function? I suspect that might be the issue.
– XTOTHEL
Nov 23 '18 at 20:22












Please, see my new UPDATE3. Maybe you get new conclusions.
– Rober
Nov 24 '18 at 7:45




Please, see my new UPDATE3. Maybe you get new conclusions.
– Rober
Nov 24 '18 at 7:45












0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53446804%2fgoogle-analytics-stopped-gathering-data-when-migrated-to-gtag-js%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53446804%2fgoogle-analytics-stopped-gathering-data-when-migrated-to-gtag-js%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

What visual should I use to simply compare current year value vs last year in Power BI desktop

How to ignore python UserWarning in pytest?

Alexandru Averescu