See the Guide https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets
I cant find any way to track Custom Variables like the old tracking js "ga.js": https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables
_setCustomVar(index, name, value, opt_scope)
Anyone can help?
thanks!
Custom Variables don't exist any more in analytics.js (aka Universal Analytics). It has been replace with Custom Dimensions and Metrics that are more flexible and powerful.
Advantages of Custom Metrics and dimensions:
They can be used in filters
They are first class citizens in the interface, so you will see the custom variable name in the interface (instead of the generic "Custom Variable 5")
Configured in the interface
Metrics that are aggregated (not possible with custom vars)
20 custom dimensions + 20 custom metrics available, instead of only 5 custom variables
In order to use Custom Dimensions/Metrics, you need to configure them on the interface. Go into admin, drill down into your web property and then there is a tab for "custom definitions".
Then when you track it, you just need to track the value and the id of the custom property eg:
ga('send', 'pageview', {
'dimension15': 'My Custom Dimension'
});
This will send a pageview with the custom dimension attached to it.
You can also set one on the page that will be applied to any pageviews or events that happened on the page.
ga('set', 'dimension5', 'custom data');
Note that only setting it won't send to GA, so if you decide to use set make sure you call a send afterwards at least once on the page to actually send that data to GA.
More Info: Developer Docs
Related
We have recently implemented a new instance of UA and GA4. With this implementation we have passed a few of our custom dimensions via custommap function in the gTag.js
gtag('config', 'GA_XXXXXXXX', {'custom_map': {'dimension1': 'product_id'}
After that we did set up custom dimensions inside the custom dimension in Google Analytics Admin
Admin > Property > Custom Definitions > Custom Dimensions > +New Custom Dimension
Now when we check our instance in the secondary dimensions we are able to see
Custom Dimensions that did set in Google Analytics Admin - but no data is being pushed in them.
No data is being pushed in these custom dimensions.
what would be the best way to debug this solution
We see another tab Custom Variables - which have values like custom variable 11 etc.
Data is coming in them.
What would be the best way to figure out the corresponding custom variable key value pair mapping from the google dev tools?
We have a site where users login to access technical information. Before accessing the information, they also have to enter a set of filter options. Different filter options result in different information displayed on different pages but the url is the same.
For example, a user will get the following URL when accessing a specific document, regardless of what filter options set:
www.site.com/fr/category/document/
Depending on the filter options, different sections of the document will be visible.
Currently, no information in GA tells us what filters were used when visiting the page. We do not want to add filter parameters to the URL. At least not for the visitor, but maybe add it in the tracking somehow?
What would be the optimal/correct way to track that kind of information?
Best solution may depends how your site works etc. But how about using custom dimensions assigned to "hit" (pageview) scope? Maybe they will help in your case? Documentation: https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets (code in documentation depends how your GA is implemented of course). Thanks to them you can send with pageviews hit additional (custom) information (e.g which filters were used).
Other way could be just sending google analytics event (https://developers.google.com/analytics/devguides/collection/analyticsjs/events) with information which filters were used before pageview hit. Then just in Google Analytics panel you can create custom segment with sequence where 2 events occurred:
Click (or use filters) - event
See specific URL - pageview
Or of course you can implement both solutions (custom dimensions for pageview and events).
I am not sure of the best way to handle this, however I am sure it is possible to implement with Google Analytics.
I currently have 1 Google Analytics account with all the data.
I would like to create 3 additional "views" within Google Analytics to filter each part of my app accordingly.
The sections are:
the landing pages landing (sales pitch)
the application pages app (the product we offer)
the customer portal pages portal (the product we offer to our user which thier users view).
So dimensions/views (unsure of the terminology here) are;
landing app and portal.
Currently I am using code like the following;
function gtag() {
dataLayer.push(arguments)
}
window.dataLayer = window.dataLayer || [], gtag("js", new Date), gtag("config", "UA-XXXXXXXXX-1", {
custom_map: {
dimension1: "website_segment"
},
website_segment: "landing"
});
I was then expecting to see these values in;
View > Filters > Custom
However they don't exist.
Please note:
I do not wish to utilize separate GA accounts to achieve this.
I cannot utilize the URL scheme with regex to achieve this.
Custom Dimensions should be available in your list of fields when you're setting up a filter for your GA view.
It looks like you're sending info to GA with the code you provided, but have you defined the Custom Dimension in your GA settings? You'll need to do that as a first step.
Access Property > Custom Definitions > Custom Dimensions, add a custom dimension, and set the scope (you'll want a Hit scope for your use case). Then ensure your code is configured to send to the dimension you just created.
See https://support.google.com/analytics/answer/2709828#Lifecycle for an overview of Custom Dimensions - though it looks like the code snippets there are out-of-date, depending on which version of GA you're using.
As far as I understand your need, it absolutely seems feasible. You collect your data in one Analytics property, and you would like to create separate views for various site content, where content is identified by a custom dimension, instead of the page path.
First, make sure, you have enabled custom dimension 1 in your property settings. As you are collecting this data on hit level, you need to set the custom dimension to hit level as well.
Second, you need to deploy your code to send this data to Google Analytics. I assume, you can substitute the proper value (landing/app/portal) for the website_segment key. Please let me know, if this is also part of your question, how to assign the proper value to the defined custom dimension.
To check if data is sent, you can use Google Analytics Debugger Chrome extension, or you can inspect the call to www.google-analytics.com in developer console / Network tab, whether cd1 parameter is set.
To verify if data is available in Google Analytics, the easiest way is to open the Behavior / Content / All pages report, and to add your custom dimension as a secondary dimension for a period, which should already contain data.
Third, you need to create your new views and your filters within Google Analytics. Please note, that you won't see any available values here, but you can still select your custom dimension, and define a filter.
I've set up e-mail tracking following this manual:
https://developers.google.com/analytics/devguides/collection/protocol/v1/email
My tracking URL is valid and seems to work since it shows up in Google Analytics (Realtime->Events), but it is showing up in the wrong view.
My Google Analytics account has an 'account' with 12 'properties' which has 3 'views'. The tracked events only show up in the first view listed (which I use for a subdomain), my 'main' view for the root domain is the second one listed and the events are not tracked in this view.
I noticed these views have a 'view ID', but I can not find a parameter in the Measurement Protocol manual that allows me to set it:
https://developers.google.com/analytics/devguides/collection/protocol/v1/parameters
How can I switch the view in which my email tracking events are stored? Or perhaps enable the tracking in my other views as well?
Data is collected on the property level, that's why there is no parameter for the measurement protocol to set the view. Views merely filter and display the data from the property.
So the events should show up by default, if not you have probably some filter that excludes the data from those particular views (e.g. something like a hostname filter, since your measurement protocol calls won't have a hostname set).
I created a google analytics account for my website and created google tag manager account too. And both of the accounts are linked and working well.
I have a new requirement which is , my client wants users to allow chance to edit there webpage and create custom templates.
Scenario is ,
User log in to the system
Go to genaral page
Use genaral page or edit genaral page and create custom template for it
Next time user log in to the system and go to the genaral page , User created Custom template appear as genaral page, But same URL
If you can get the point , Same URL but the content is different ,
I applied google tag manager to track those pages, Because of having same URL its tracking as a same url,
But I want to track the page by content and track user if user used my genaral template or custom template.
Hope any one will have a idea to how to create Google Tag or Macro or Rule , Or custom java script for it.
Thanks in advance
By far the best way would be to include a dataLayer variable into your templates that indicated which template is being used. Best to include it above the tag manager code:
<body>
<script>
dataLayer = [{
'template': 'default',
}];
</script>
<!-- Google Tag Manager -->
...
<!-- End Google Tag Manager -->
so it's immediatly available when the GTM code loads. Then create a dataLayer variable in GTM that reads the value for the "template" key from the dataLayer and pass it as a hit based custom dimension to Google Analytics (i.e. in the property settings in GA under "custom definitions" you create a new custom dimension and set the scope to "hit"; in GTM you go to "more settings/custom dimensions", add the numeric index of the dimension you have just created and pass your new dataLayer variable as dimension value). Then you can segment your page hits in Google Analytics based on template type.
I'm sure it would be also possible to track by content (i.e. you could load the content into a js string variable, create a hash value from the string and send that as a custom dimension), but that would mean even fixing typos would result in a new id. Using a variable per template seems much more prudent.
If supposedly your different templates have some ID's in the code - you can use this ID as identifier for the template and create variable to check if the ID is present, then fire it in GA, in similar way as the Eike's description.
But this is the sloppy way, and it's an option if you have no way to create dataLayer push for the new templates, as described by Eike. Otherwise the dataLayer push is the better way to do the job.