I tried to setup Google Tag Manager. The Pageviews are tracked correctly, but in Universal Analytics I can not see Custom Dimensions.
In Google Universal Analytics:
I have defined some custom dimensions in the Universal Analytics Profile under "Admin" -> "Custom Definitions" -> "Custom Dimensions".
The following Dimensions are relevant:
(Name) (Index)
PageView Author 7
PageView Themenwelt 8
PageView Seitentyp 9
PageView Posttyp 10
PageView Modified Date 11
In Google Tag Manager:
I have added a page Universal Analytics Tag with Track Type "Page View" and the following settings for "Custom Dimensions":
(Index) (Dimension)
7 {{Tracking Variable Posttyp}}
9 {{Tracking Variable Seitentyp}}
8 {{Tracking Variable Themenwelt}}
7 {{Tracking Variable Autor}}
11 {{Tracking Variable Modified Date}}
The values for the dimensions are fetched via Macros, using the "Javascript Variable" Macro.
Example for such a macro is just:
Global Variable Name: window.analytics_tracking_params.Author
The Variable is defined in the Website content, before the tag manager code.
When I go to the debug mode of tag manager, I can see the event being triggered, with the following debug entry for "Dimension":
{
7: Tracking Variable Autor,
8: Tracking Variable Themenwelt,
9: Tracking Variable Seitentyp,
10: Tracking Variable Posttyp,
11: Tracking Variable Modified Date,
}
The Macros resolve correctly to the values set on the website.
----------> I believe that the Google Tag Manager Setup is correct.
Again, in Google Universal Analytics:
I have created a Custom Report ("Customization" -> "+New Custom Report") with the following settings:
Metric Groups: Pageviews (Users)
Dimension Drilldowns: PageView Posttyp (Custom Dimensions)
In the report table below the Chart, there is only this message "There is no data for this view.".
This happens regardless of which Custom Dimension I chose.
----------> I believe that the Settings in Google Universal Analytics are correct, but apparently something does not work as expected.
It seems the Data is not correctly sent to Universal Analytics OR Universal Analytics is not able to process the Data and display it. Is there anything I might have forgotten or misunderstood?
I encountered a similar problem with my GTM configuration. I had my macro retrieving the values for my custom dimensions set up to fill in an empty string as a default value (see checkbox for default value: "To set the default value to be an empty string, select this option and leave the text field blank.").
Unfortunately my custom dimension was overwritten at some places with the empty string, so in GA pagehits etc. were recorded but the custom dimensions have been set to blank.
I changed that with unchecking the default value box, so instead of a empty string a nil value (or in JS: undefined) will be used instead. With that setting my custom dimension haven't got overwritten again with empty strings.
Maybe that might fix your problem as well?
see if your custom dimensions can be seen as aseconday dimension in the events sections. If you can you are probably look at standard user reports. Custom reports easily populate custom dimensions.
Related
We are using Google Tag Manager. It is sending a custom dimension to Google Analytics with a value of {{fc-isSubscribedSession}} variable
The fc-isSubscribedSession variable is a DOM variable that is taken from the data-is-subscribed-session attribute on the page body.
We are migrating our platform. The old user interface makes use of the tag and the data-is-subscribed-session attribute. The new user interface is more like SPA so we are using the data layer to push the data to GTM like
window.dataLayer.push({
'newInterfaceIsSubscribedSession': current_user.is_subscribed?
});
(above is a fragment that is close enough to the real call)
Now the problem is that we must fill the dimension from fc-isSubscribedSession or from newInterfaceIsSubscribedSession.
Do you know if there is a way to fill a dimension from one of two values?
Something like
{{fc-isSusbscribedSession}} or {{newInterfaceIsSubscribedSession}}
In Google Analytics Classic/Universal Analytics we could get the name of global object using such code:
window['GoogleAnalyticsObject']
And then we could get the object by its name:
window[window['GoogleAnalyticsObject']]
Looks like in GA4 such approach is not working, I am getting undefined if I try to get this name. Is it possible somehow to get this name in GA4 ?
Also this is my use case: I have a site on which GA4 was added, there is a possibility that the global object - gtag was renamed (but I don't know about that), theafore I need to get current name of the object and then to get the object by its name.
Per the updated Google Analytics 4 site tag documentation, it appears that object may now be in window.dataLayer. I'm thinking either:
window[window.dataLayer['GoogleAnalyticsObject']]
or
window.dataLayer['GoogleAnalyticsObject']
I'm trying to use Google Analytics as a data stream for Google Data Studio but it requires me to have a property view. There is no option for me to create a view in my property in the administration page:
There is no column named Views:
Is there something I need to do to be able to create new views?
OBS.: My Google Analytics account was imported directly from Firebase.
Google Analytics is changing and it is a bit confusing. I will try to clarify it for you. As far as I have gone, evolution has been:
1.- "App + web property" (Beta phase)
2.- "Universal Analytics" (*) (until 14-Oct-2020): It is identified because the account number is preceded by "UA-" eg. UA-123456789 (Attention, sometimes it is not very obvious and you have to create a new user to see the UA prefix). This option is only suitable for the monitoring and analysis of Web pages and has the option of analysis using "Views" enabled. If you don't have it, you should:
2.a.- Create a new "Property"
2.b.- "Show advanced options"
2.c.- Activate "Create an Analytics Property"
2.d.- Create only one "Universal Analytics" Property
3.- "Google Analytics 4": It is identified because the account number is preceded by "GA4-" eg. GA4-123456789. In this case, the analysis is not done through "View" but through "Data Stream" (** incorporating a series of improvements) although Google offers the possibility of creating two "Properties" one in UA format with Views and another in GA4 format with Data Stream
In all cases, you must place the corresponding gtag provided by Google Analytics within the tag of the page you want to analyze.
Sources
(*) https://support.google.com/analytics/answer/10089681?hl=es&utm_id=ad
(**) https://support.google.com/analytics/answer/9216061?hl=es&utm_id=ad
https://support.google.com/analytics/answer/9367631
https://support.google.com/analytics/answer/9539598?hl=en#:~:text=If%20you%20set%20up%20a,with%20%22UA%2D%22).
This is a good answer to that question. I had the same problem. In case the URL doesn't load, essentially,...
"If you set up a Google Analytics 4 property with a Web data stream, you have a Measurement ID (which begins with "G-").
If you set up a Universal Analytics ("Web") property (Universal Analytics properties have views instead of data streams), you have a Tracking ID (which begins with "UA-")."
You cannot have the property be a Google Analytics 4 property with a web data stream and have a view page as well. If you want the View page, then when you create the property, make sure its Universal Analytics.
Hope this helps, I'm new to this game.
I want to add a Custom Variables called Custom Variables to my website.And I defined a datalayer on Google Tag Manager.I also add the code snippet on the page which I want to get the Custom Variable.
<script type="text/javascript">
var external_id = jQuery('#edit-external-id').attr("value");
dataLayer = [{
'externalID': external_id
}];
</script>
I debuged the configuration of GTM.Here's the picture
I got the message.But I can't see the value statics on my Google Analytics.I think the menu path of GA is Audience-Custom-Custom Variable.Am I right?Anyone can help me?
Writing values to the dataLayer does not make them appear in Google Analytics; it just makes them available in GTM.
You need to set up a Google Analytics Tag - there is a tag template for Universal Analytics where you can insert the Google Account id. Use the default "all pages" trigger. Since you are receiving data I assume you already have done this.
Now in GTM go to the "variables" menu, click "new" and select "Data Layer Variable" as type. Enter the key from the dataLayer that you want to be evaluated, i.e. "externalID". Give your variable a name, I suggest to simply use the dataLayer key. Save. Now you can use the variable by calling it via its name surrounded by {{curly brackets}}.
Go back to your GA tag. I assume you want to save the value as custom dimension, since custom variables are deprecated in the current GA version. You need to create a custom dimension in Admin/Property/Custom Definitions/Custom Dimensions. When you create a custom dimension you will get a numeric index to address the dimension by. Go to your GA tag, advanced configuration, custom dimensions and click "add". Enter the numeric index and after that select the variable you want to send.
Custom variables do not show up by default in the standard reports; you can either selected them as "secondary dimension" from the dropdown above the data table, or create a custom report.
First, you must never, ever use dataLayer = [{...}] after the container snippet (preferably don't use it ever). You're overwriting the container snippet by reinitializing it as a new Array. As you can see, in your Preview panel there is no "Page View" event (should be just before DOM Ready), which means e.g. the All Pages Trigger won't work.
Second, "Custom Variables" are deprecated. They've been replaced with Custom Dimensions in Universal Analytics.
Third, did you actually add this variable/dimension to a GA Tag?
Here's how it should work:
1) In your script replace dataLayer = [{...}] with:
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event' : 'variablePushed',
'externalID' : external_id
});
This is the safe way to interact with dataLayer.
2) In GA Admin / Property Settings / Custom Definitions / Custom Dimensions, create a new Custom Dimension with the appropriate scope, and make note of the assigned Index number. If you are unfamiliar with Custom Dimensions, you have some reading to do. Start with https://support.google.com/analytics/answer/2709828?hl=en
3) Create a new Custom Event Trigger for Event Name variablePushed, name it e.g. "Event - variablePushed" (without quotes).
4) Create a new Data Layer Variable for Variable Name externalID, name it e.g. {{externalID}} (without curly braces).
5) Create a new Event Tag, with Event Category: External ID, Event Action: {{externalID}}, and set the Non-Interaction field to True.
6) Browse to More Settings -> Custom Dimensions in the Event Tag, and add a new Custom Dimension. Set the Index number from (2) and set the value to {{externalID}}.
7) Add the Trigger you created in (3) to this Event Tag.
What happens now is that when the externalID dataLayer.push() takes place, the Event Tag fires a non-interaction event to GA (so it won't affect Bounce Rate), which piggybacks the Custom Dimension with it.
I want to create a custom report with custom dimensions and custom metrics, so I've created them as admin in GA and both have index 1.
I've added them in the dataLayer in my code:
var dataLayer = {'dimension1':'Custom Dimension 1','metric1':123456}
And after setting in GTM, I've checked data is being sent right in live mode:
But custom reports are empty, but activity on site is being registered.
This is the entire code of my site. I have tried adding both Google Tag Manager and Google Adwords codes but does not work in any case:
<body>
<script>
var dataLayer = [{
'dimension1':'My Custom Dimension 1',
'metric1': 123456
}]
</script>
<!-- Google Tag Manager -->
<!-- End Google Tag Manager -->
<h1>Nuevo alojamiento</h1>
<script>
//GA CODE
ga('create', 'UA-76206495-2', 'auto');
ga('send', 'pageview');
</script>
</body>
Pushing those values with those standard reference names in to GTM will not associate them with your hits, or make them show up in your reports. In GTM you need to grab the value of your CD and CM from the dataLayer. In this case you need to create dataLayer type variables that will give you access to dimension1 and metric1, although I would advise to rename them to something else other than the standard GA reference names, ie. dimensionX and metricX because that could be confusing. Then you need to pass the index and value for that CD and CM into whichever tag (page view, event, etc.) using those new names.
Edit: note that data won't show up in your standard reports until they have been processed, which takes up to 24 hours or so.
As nyuen told me, I have to set those values in GTM, it was done bescause, if it wouldn't, data would not been sent. These are my settings
This sends the CD and CM in all pages. Custom vars are already set.
Preview mode of CTM displays this, it was fired:
And de dataLayer contains the data (I'm going to follow you advice and use another name):
So if I leave the preview mode and publish in GTM, I'm sure information is being sent, that is the GET request I placed before. Those values era in the URL as params (cd1 and cm1), so that is the reason why I'm pretty sure information is being sent to GA
Hope this extra information helps
UPDATE 1
I've changed dataLayer values to dim1 and met1 and now met1 is set to 123456789. Also, verified UA is right.
With those changes, chain sent to Google Analytics is the same (params are cd1 and cm1 with the appropiate values)