Have just done a migration from 2.2.2 to 2.3.3.
Initially once migration was completed, no data at all was recording in google analytics screen.
We the checked Analytics setting in the backend of the store:
Stores>Configuration>Sales>Google API>Google Analytics
It was disabled so we enabled it.
Prior to migration, daily new users: 500.
After migration, daily new users for the last 2 days: 140.
Conversions: unaffected
Conclusion: analytics is not recording the data correctly.
Can anyone advise what else could be investigated why the data isn't accurate after 48hrs+?
and I can see also some google code in:
public_html/app/design/frontend/[vendor name]/[theme name]/Magento_Theme/templates/html/footer.phtml
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXXX-X"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXXX-X');
</script>```
The code is the standard one (it shouldn't be in the footer but in the header) and it track the pageviews, if it is in all pages you should have no user or session detection issues. Check if it is present on all pages. In addition, on the purchase confirmation page there must be the transaction code in addition to the one you entered here.
Related
I have implemented a feedback star rating on my website at the bottom of each page. They can select one to five stars and optionally send free-form comments. I have implemented gtag.js to send the star rating integer and comments to my GA4 dashboard. Code snippet is below; I have omitted the JavaScript which allows the user to set the variables, but this is working.
<script async src="https://www.googletagmanager.com/gtag/js?id=MEASUREMENT_ID"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'MEASUREMENT_ID', {
'custom_map': {
'rating_dimension': 'rating_key',
'comments_dimension': 'comments_key'
},
'rating_key': 'this.value',
'comments_key': 'commentsValue',
});
</script>
gtag('event', 'rating_event', {'rating_key': this.value });
gtag('event', 'comments_event', {'comments_key': commentValue });
I went under Configure>Custom definitions and added the dimensions under the Event scope.
The data is being sent as an event, because this is something the user can optionally do on a page. I have verified that the data is sent to GA, I have the Google Chrome GA Debugger, and can see that it is arriving in the Realtime report under Events.
I would like to build a report which shows the page title/URL, the number of views, the length of time spent, along with its average star rating and any comments. I would like to have some adjustable controls so that I can configure this to be shown for a specified length of time. For example, if the page is modified, I can see the average rating before and after the change. Unfortunately, I am not able to build even the most rudimentary view of this data in the new GA web interface. I tried to modify various existing reports to include my custom dimensions, but they don't offer this option. I went under Explore and tried to add a Freeform report, but I can't get the data to show up there either, it only counts the number of times the event has occurred, which is not what I care about at all.
I have gone to a lot of effort to send the data to GA and had expected to be able to access the data and build a basic report.
Is it that you are unable to add custom dimensions and metrics to the free form exploration? Or when you want to add dimensions or metrics, they don't even show up in the custom section?
Normally you have to wait more or less (some say up to) 24 hours before being able to use custom definitions (metrics and dimensions) in any report.
this might not be your case, but I found your post looking for an answer to my problem, which is the custom metrics and dimensions are there, I am just unable to add them to the report, it looks like a bug, I click the + button, check the custom dimensions and nothing happens.
My google analytics script is like this
< !--Global site tag(gtag.js) - Google Analytics-- >
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxx-x"></ script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-xxxxxxx-x', { 'page_path': curpath });
</script>
Thiw works fine except Avg. Page Load Time is not getting logged in analytics (always shows as zero). What am I missing here?
Note: My site works on ajax calls with single URL
You are missing the necessary information from the browser, since you use AJAX calls.
Google Analytics uses the Navigation Timing API, which is quite reliable, since the actual measurement is done by the browser and the values can be read as properties of the window.performance.timing object.
Example from here:
Calculate the total page load time
const perfData = window.performance.timing;
const pageLoadTime = perfData.loadEventEnd - perfData.navigationStart;
Your Ajax call does not populate those values (which in a way makes sense, since the corresponding DOM events are not populated in an AJAX call), so GA cannot log a page load time.
You can do custom user timings in GA. They will be limited to a sample of 1% of your calls max, and your averages will be extrapolated from there. You would pass in the delta between the start of your Ajax call and the point at which the response is rendered.
I'm trying to setup event tracking for google analytics, and I've got the following code:
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-XXXXXXXX-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config','UA-XXXXXXXX-1');
</script>
onclick="javascript:gtag('event','Download',{'event_category':'Teacher Guide - Agroforestry','event_label':'Teacher Resource','value':'Teacher Resource'});"
It's displaying under Real-Time > Events if I click on the link, but it doesn't display under Behaviour -> Events -> Overview.
Could someone tell me if I'm missing something, or if I've set it up incorrectly?
It seems like you are using GA free.
If you are seeing the events real time, then you need to wait for at least 24-72 hrs to get the data updated under Behaviour -> Events -> Overview.
If you are a GA 360 customer, then you have to wait about 2 hrs to get the data in the reports
I have a custom dimension that is being set with a gtag tracking code. I can actually see that the values are being send to GA and can, for example, make dashboard widgets with it.
The odd thing is that when I make a widget with sessions and the dimension it works well, but if I want to make a widget with pageviews and the dimension it returns no data at all.
This is my tracking code:
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-0000000-0', {"anonymize_ip":true,"custom_map":{"dimension1":"premium"}});
gtag('set', 'premium', {'premium': 'premium post and not subscribed'});
I've also, instead of using 'set' tried using 'event' but this did not solve the issue. It looks like the custom dimension is not being collected with pageviews, but with sessions only.
Does anyone know if I have to configure it differently to also make it work for pageviews?
Since your custom dimension is configured at the hit level it needs to be associated with either an event or pageview hit. Your code looks like it simply sets the custom dimension value, but it's not followed by a pageview hit call. Try swapping the idea of your calls instead:
gtag('set', 'premium', {'premium': 'premium post and not subscribed'});
gtag('config', 'UA-0000000-0', {"anonymize_ip":true,"custom_map":{"dimension1":"premium"}});
I'm looking for some assistance here. We're seeing a very low bounce rate (3%) which i know can't be possible.
The analytics appears to be setup incorrectly on our site. We see a lot of event tracking that happens automatically so i'm pretty sure this is our problem. Here is the code we're seeing that was implemented in what looks to be twice. Which do we need to get rid of?
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-xxxxxxx-
1`enter code here`"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-xxxxxxx-1');
</script>
Any help is appreciated.
Thanks,
gr8rck
The snippet you've provided looks fine. If the same set of code has been provided twice, remove one of the instances.
You mentioned that a series of events fire automatically. This is most likely what is causing an artificially low bounce rate.
If these events fire without user involvement, my suggestion is that you define them as non-interaction events. The events will still record, but will not count as a true user interaction. Therefore your bounce rate will be unaffected.
You would send a non-interaction event like so:
gtag('event', 'my_event_action', {
'event_label': 'my_event_label',
'event_category': 'my_event_category',
'non_interaction': true
});