GA/GTM Custom Dimension Error (Undefined) - google-analytics

kindly ask you to help me with custom dimensions, as i'm newbie for GA/GTM and did everything per manual.
1) So i created 3 new dimensions for ecommerce in GA:
here is dimensions from GA with indexes
2) I've created snipped in GA and added it into head section of my site:
<script> gtag('event', 'page_view', {
'send_to': 'AW-XXXXXXX',
'ecomm_pagetype': 'page_type',
'ecomm_prodid': 'product_ids',
'ecomm_totalvalue': 'total_value',
'user_id': ‘userId’ }); </script>
along with global site tag.
3) Finally i've created new variables in GTM:
for example for page_type
and in Tag itself.
but i constantly getting error on debug:
{index: '1', dimension:undefined}
screenshot is here
will really appreciate any help!
p.s. sorry for links with images instead embedding, i have not enough reputation here yet.

You clearly are mistaken the gtag which stands for global site tag with the tag manager code.
Instead of using gtag use dataLayer.push, this is the method to push information to Google Tag Manager.
An example:
dataLayer.push({
'ecomm_pagetype' : Variable1,
'ecomm_prodid' : Variable2,
'ecomm_totalvalue' : Variable3
});
Here you have the docs for further reference: docs
Remember to place this tag under the Tag Manager snippet. or remember to initialize an empty dataLayer as the doc states.

Code on page
On your page, before your GTM container snippet add the following (I've used sample values for type, id and value), your code should look like below:
<script>
dataLayer = [{
'ecomm_pagetype': 'MyPageType',
'ecomm_prodid': 'EXAMPLE0000001',
'ecomm_totalvalue': '4000',
}];
</script>
<!-- Google Tag Manager -->
<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-XXXXXX');</script>
<!-- End Google Tag Manager -->
GTM - Data Layer Variables
In GTM, create 3 data layer variables for "ecomm_pagetype", "ecomm_prodid", "ecomm_totalvalue" like so:
Type in the key(name) that's in the datalyer object, you can set a default value if you like, otherwise, it will be "undefined" for pages without this variable defined.
Next create a "Google Analytics Settings" variable, this is to simply GA tag configuration, we will link the custom dimensions here.
Put in your own GA property ID, under "More Settings" expand to "Custom Dimensions", click on "ADD CUSTOM DIMENSION". Put in "1" for to reference the index for "ecomm_pagetype" CD in GA. For value, use the variable we created earlier. Do this for all 3 CDs.
Now your Variables page should look something like this:
GTM - Tags, adding CDs to GA tag
Now for your tag. You should have a Google Analytics tag configured in GTM. Looks like you know how to do that, to add the custom dimensions by using the new "My GA Variable" under "Google Analytics Settings". Don't forget to have this trigger on "All pages" or pick your own trigger as you see fit.

Related

Can I populate a custom dimension in google analytics from page metadata?

I'm trying to report on website performance for a website with editors in various UK regions (Eg. South-West, North, North-East) that don't map to regions that GA understands.
Is it possible to embed the region into the metadata of the page and then read that via Google Analytics as a hit for a custom dimension? If so how do I format the metadata tag on the page?
You can absolutely do this. On your page, below wherever it is that you have the Google Tag Manager script, you'll want to push your values into the data layer. I recommend something along the lines of the following:
<script type="text/javascript">
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'uk-region': 'South-West' //As applicable
});
</script>
And then you'll need a couple of things in GTM in order to pick this up. First, create a new Data Layer Variable and populate the "Data Layer Variable Name" with the "uk-region" name I used above, or whatever else you want to identify it with. Give it a useful name like "uk-region" at the top.
In your Google Analytics page view tag then, you'll need to set up the custom dimension mapping. Click the box for "Enable overriding settings in this tag" and a dropdown will appear with "More Settings". Expand the "Custom Dimensions" and click the "+ Add Custom Dimension" button. Specify the number custom dimension you wish to populate under Index and in the value, we'll specify the variable we created with {{uk-region}}.
Test your container to ensure it's getting picked up as it should, then publish to commit the container to your website.

How to assign Google Tag Manager Custom Variable to Google Analytics Custom Dimension

I am new to Google Tag Manager and Google Analytics. Having set up basic tags in GTM that are mapped to Google Analytics I want to get improved insights by using HTML meta tag data To that end I have created a custom GTM variable with the following JS:
var metaNames = ["foo", "bar", "blah" ];
var metas = document.getElementsByTagName('meta');
var content = undefined;
for (i = 0; i < metas.length; i++){
if (metaNames.contains(metas[i].getAttribute("property"))){
content = metas[i].getAttribute("content");
}
}
return content;
}
Having read Google documentation and searched the web I cannot figure out how to map the GTM variable to a GA "Custom Definition" or "Custom Metric". The "User Property" / "Event Parameter" field in GA does not appear to correspond to the GTM variable.
I want GA to use the GTM variable to produce analytics based upon the page meta data properties identified above.
Any assistance would be gratefully received.
Thanks and regards,
Andrew
I have figured this out, under GTM Tag configuration the GTM variables need to be mapped to GA4 "Fields to set" or "User Properties". The variable will then be sent as part of the event fired by GTM

How to set `ga_session_id` with google tag manager (GTM)?

I would like to set the ga_session_id that gets reported in google analytics (along with other event parameters) dynamically. With global site tag (gtag.js) I can make the following call to set the ga_session_id:
gtag('config', 'GA_MEASUREMENT_ID', {
session_id: 'my_custom_session_id'
})
How can I accomplish the same thing in GTM?
Set the field session_id in the GA4 settings tag.

Google Tag Manager - custom event - category is undefined

I have started using Google Tag Manager recently and I don't understand why one of my variables remains undefined while everything seems to be set up correctly.
Here is first the code that I use to create my datalayer:
<script>
window.dataLayer = [{
'pageCategory': 'test1',
'Device' : 'test2',
'Manufacturer': 'test3'
}];
</script>
I have created custom dimensions based on those variables and I can find them in Google Analytics. So far, everything is all right.
I then want to track a click on a button that leads the users to an external link. I use the following code:
window.dataLayer.push({
'ShopURL': url,
'ShopName': shop_name,
'PriceOffer': price,
'event': 'ClickPrice'
});
I have checked the content of each variable with a console.log and they all display the correct values.
In GTM, I have created datalayer variable for each one of them, I have created a custom event to push them to Google Analytics. I have taken "ShopName" for event_category, "Device" for event_action, "PriceOffer" for event_label.
When I look at the data in Google Analytics I see that event_category is undefined while event_action has the correct value. It looks like the event is fired correctly because I can only see it in GA when I click on the button but somehow some variables are not populated correctly.
You can see it in action here: https://www.mobilemultimedia.be/en/nokia/price-nokia-8.1 (click on one of the "check offer" button to trigger the event)
With GTM preview in the browser I see all the correct values.
Any idea?
Additional info
Here is a screenshot of the variable configuration in GTM:
I'm sorry, it's in French but you can see the variable with the right name.
I believe you have your trigger set incorrectly.
I think it might be an element click trigger right now, but you need it to be a "custom event" trigger and you should have "ClickPrice" as the event name you use to trigger.
Like so:

Issue with Dynamic Remarketing Tag. The Product ID parameter is missing in 99% of the activity

When I go to Tag Google Ads details, I have this issue: "The “Product ID” parameter is missing in 99% of the activity of your Google Ads Tag".
Note, I implemented Dynamic Remarketing Tag via Google Tag Manager. In setting up Tag "Remarketing Google Ads" I inserted:
ID Conversion: XXX-XXX-XXX;
Custom Parameters: Use Data Layer {{google_tag_params}};
Trigger: All pages.
Following you can see source code html for a product page that contains ecomm_prodid, ecomm_pagetype, ecomm_totalvalue:
<!-- BEGIN: Google TagManager Remaketing -->
<script>
var dataLayer = window.dataLayer || [];
dataLayer.push({
'event':'remarketingTriggered',
'google_tag_params': {
'ecomm_prodid': '721',
'ecomm_pname': 'MAGLIONE GIROCOLLO IN LANA',
'ecomm_pcat': 'home',
'ecomm_pagetype': 'product',
'ecomm_totalvalue': '20.00'
}
});
</script>
<!-- END: Google TagManager Remaketing -->
So, I created in GTM a variable called google_tag_params with:
Data Layer Variable Name: google_tag_params;
Data Layer Version: Version 2.
As seen before, I used this variable in Remarketing Google Ads Tag, trying to capture at least: ecomm_prodid, ecomm_pagetype, ecomm_totalvalue needed to Display Remarketing.
When I use GTM in preview mode I have this:
Send dynamic remarketing event data: false
Variabile di livello dati:
{ecomm_prodid: '721',
ecomm_pname: 'MAGLIONE GIROCOLLO IN LANA',
ecomm_pcat: 'home',
ecomm_pagetype: 'product',
ecomm_totalvalue: '20.00'}
ID conversione: 'XXX-XXX-XXX'
Parametri personalizzati: 'DATA_LAYER'
Problem is issue "The “Product ID” parameter is missing in 99% of the activity of your Google Ads Tag" is still there.
I tried also check via Tag Assistant with Product Feed ID XXX-XXX-XXX, but I got this alert: Some products are not valid.
When I check on Metadata request in Tag Assistant I got this "event:gtag.config" and not parameters.
I searched for days on web, but did not find any solution.
Could you please assist me?
Thanks,
Francesco
Try the following:
Create a dataLayer variable for each of your dynamic remarketing variable.
google_tag_params.ecomm_prodid
google_tag_params.ecomm_pname
google_tag_params.ecomm_pcat
google_tag_params.ecomm_pagetype
google_tag_params.ecomm_totalvalue
Use the following custom event as you have in the dataLayer event field.
Use the manually specify on your AdWords tag:
Verify the implementation by checking in your browser network tab, filtering by the keyword random. You should see the dynamic remarketing request along with the key/value you've provided.

Resources