Getting pageview-level reporting with Google Analytics custom dimensions - google-analytics

I've switched from analytics.js to gtag.js and I'm having problems with reporting.
I have a number of custom dimensions set as hit-level variables (author, for instance) and have updated our code to send the gtag(event).
I see the right number of events coming in, (about 100,000 author events per 100,000 pageviews) however they no longer report with the Pageviews metric.
I see very few Author results using the Pageview metric (only a few hundred results). I'm actually seeing better Author results with the Users metric (a few thousand results, but not nearly 100,000).
Event reporting seems to be running correctly so the data is being entered into GA, but I can't seem to get the old reporting to work.
Current code set in head
gtag('config', GOOGLEID, { 'custom_map': {
'dimension1': 'Author',
'dimension2': 'Primary Taxonomy',
'dimension3': 'Primary Type' }
})
event sent near bottom of body (crna_ variables set in body)
gtag('event', 'set-dimensions', {
'Author': crna_author,
'Primary Taxonomy': crna_primarytax,
'Primary Type': crna_primarytype
});
Any suggestions on how to troubleshoot? Thanks.

Related

Cannot create reports for custom dimensions/metrics GA4

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.

Custom Dimension doesn't show up in Google Analytics

I have the following custom dimension parameter that I'm sending on page view:
ga('send', 'pageview', { 'environment': 'DEV' });
(DEV changes depending on the website environment)
I logged into Google Analytics => Admin => Custom Definitions/Custom Dimensions, then "New Custom Dimension" and added "environment", Scope = Hit.
I created a custom report that included Pageviews as the Metric and "environment" as the Dimension and I don't see any information for the custom dimension I added. The js has been in there for several weeks (throughout our development cycle) so I would expect to see some information.
Am I missing a step somewhere?
Bear with me if I'm calling something by the wrong name, I'm relatively new to Google Analytics.
Thanks
JH
The custom dimensions are set by number, what you have named them in the GA interface shouldn't appear in the code. So for your example you'd have
ga('send', 'pageview', {
'dimensionX': 'DEV'
});
where X is the number of the dimension you wish to set.

Google Analytics Global Site Tag Custom Parameters

According to Google's gtag.js guide, it seems like we're able to define custom parameters. However, when using the code examples, only the Event Action gets populated. The Event Label is recorded in Google Analytics as "(not set)" and the Event Category as "general".
Code Example from developers.google.com:
gtag('event', 'video_play', {
'video_title': 'My promotional video',
'duration': '01:32'
});
It's also interesting to note that I cannot figure out how to show custom parameters as the columns in Google Analytics seem to be statically set to "Event Category", "Event Action", and "Event Label". These correspond to the default keys of "event_category", "event_action", and "event_label". Using these keys sends the values correctly. The following code works:
gtag('event', 'redirect', {
'event_category': 'Announcements',
'event_label': '/announcements/index.jsp',
Has anyone gotten custom parameters to work or is this a feature that hasn't been implemented yet in gtag.js? Is there additional configuration needed that I may have missed?
If you you were thinking of GA Custom Dimensions and Custom Metrics, yes it is available in the gtag.js / Global Site Tag syntax, see
https://developers.google.com/analytics/devguides/collection/gtagjs/custom-dims-mets
in the form of a Map of CD indexes and attribute explicit names, followed by setting values to explicit attribute names.
for example
// Maps 'dimension2' to 'age'.
gtag('config', 'GA_MEASUREMENT_ID', {
'custom_map': {'dimension2': 'age'}
});
// Sends an event that passes 'age' as a parameter.
gtag('event', 'age_dimension', {'age': 55});
See also https://developers.google.com/analytics/devguides/collection/gtagjs/migration#custom_dimensions_and_metrics
However, gtag.js is a wrapper to make analytics.js easier to implement by hiding some its complexity.
If you are used to analytics.js, keep using it, you get more control on its behavior.
Or move to GTM, it's way more flexible.

Google Analytics - Some ecommerce transactions are not showing in GA

We have implemented Google Analytics Ecommerce tracking in our web site. We have noted that there are some missing transactions from Google Analytics. Only some data get missing and other transactions are recorded correctly.
There is no specific pattern to those missing orders (e.g. the products that are selected, the device they are using...etc).
Below is the code snippet that push transaction data to analytics.
var products = [];
for (i = 0; i < cart.lines.length; i++) {
var cartItem = cart.lines[i];
if (cartItem != null && cartItem != 'undefined') {
products.push({
'name': cartItem.cartProduct.name + ' ($' + cartItem.cost + ')',
'id': cartItem.cartProduct.id ,
'price': cartItem.cost,
'brand': 'My Brand XXX',
'category': cartItem.category,
'variant': 'My Brand XXX',
'quantity': 1 // Iterating item by item therefore hardcoding quantity to 1
});
}
}
// Pushing ecommerce transaction data to data layer
window.dataLayer = window.dataLayer || [];
dataLayer.push({
'ecommerce': {
'purchase': {
'actionField': {
'id': cart.referenceNumber, // Transaction ID. Required for purchases and refunds.
'affiliation': store.name,
'revenue': cart.totalPrice, // Total transaction value (incl. tax and shipping)
'tax': 0,
'shipping': cart.deliveryCharge,
'coupon': ''
},
'products': products
}
},
'event': 'purchase'
});
}
Note that I have the fully populated 'cart' and 'store' objects accessible.
Appreciate if anyone could help to figure out what's causing this.
Well, Your code seems fine. There isn't any specific way to identify the way what is causing this issue.
You can implement exception tracking in above particular code, by that you will get to know the possible reason which is causing the issue.
To implement exception tracking using GTM you need to wrap up the above code in try catch block and in catch block you push the datalayer event with the exception detail. On other side in GTM configure the exception tracking tag.
Hope this will help you. Let me know in case of any help needed to implement exception tracking.
As Google Analytic is Javascript based platform, there could be a lot of reasons the transaction could be missing, some of the obvious reasons are outlined below -:
Ad blocker is enabled on your browser
JavaScript is disabled
Cookies are turned off
Customer left the page before transaction was sent to Google
Analytics
Payment gateway is not redirecting customers to your order
confirmation page
Order confirmation page may not load for certain payment methods
GDPR extensions can also prevent transactions from reaching Google
Analytics
In the past we have used one of the extensions for our Magento 2 site to sync missing orders between Magento and Google using Measurement Protocol API
Whatever platform you might be using, Measurement Protocol API could be utilised to synch orders between the two system and give you 100% sales data view in Analytics.
If you use a third-party payment processor for some but not all transactions - common example, you accept credit cards on your website but you also accept PayPal payments where the buyer is taken to the PayPal site to complete the transaction - the ones who leave your site to pay are often not counted.
Two reasons: one, many buyers leave straight from PayPal - they never view the order confirmation page where your tracking code is set to send the data to GA.
Two, they're tracked separately because they've technically left your website and then returned, so you need to set up cross-domain tracking to associate them with the correct user session.
(I know this answer is rather late for the OP but thought it might help someone else in a similar situation.)

How much time it takes to update google analytics reporting for event tracking?

I have implemented onclick javascript code into my website on different places with different parameters like following:
onClick="ga('send', '_trackEvent', { eventCategory: 'Property Listing Search', eventAction: 'Property Listing Search button', eventLabel: 'Searchbuttonclicked', eventValue: 5});"
i want to know that how much time it will take to update the data of triggering respective events with respective category and action??
for now i don't want to create any goal for there onclick events..
Please let me know....
Thanks in advance.
There is a slight error in the code you posted. You should be using
ga('send', 'event', 'some category', 'some action', 'some label', 'some value');
You can check GA debugger to see if the event is sent in real time or check the Real Time reports, otherwise you need to wait up to 24 hours to see it in your standard reports.

Resources