Im looking into some better data tracking for our website.
User would do a search on a search form for hotels.
It will populate the datalayer with useful information, ie:
dataLayer = [
'event' => 'hotelSearch',
'destination' => 'London',
'date' => '2015-12-01',
'stay' => '5 nights'
];
I would like to store those custom data into Google Analytics with the help of GTM.
Is that something that is possible?
So the marketer here can go into GA, have a look at how many people searched for London in the last week or see whats the average stay per destination?
Thanks
As long as you are pushing the needed values into the datalayer, you can leverage GTM to grab those values by creating new variables for each dataLayer parameter. Not only will that data be available in GA now, but you can use them however you want through GTM.
To create a custom dimension in GA, just go to the Property column in the admin console and select Custom Dimension:
Create custom dimensions in your GA account to capture those values that you are pushing (note the limit of custom dimensions though, which is 20). When you go to plug that custom dimension into GTM, remember the slot number you've created it in (slot 7 in this example):
To grab those values through GTM, create new variables for each parameter, one for "destination", one for "name", and for "stay". Be sure to use the exact name as you are using in the dataLayer:
Now when you push the values into the dataLayer, they will be available for you to use in GTM. The values will then be shown in your GA reports.
In Google Analytics Admin
Custom Definitions -> Custom Dimensions -> NEW -> Name: Destination; scope HIT (cd1)
Name: Stay; scope HIT (cd2)
Name: Date; scope HIT (cd3)
In Google Tag Manager
Config Tag with your custom event configuration:
More Settings -> Custom Dimensions -> index: 1 - Dimension Value: {{destination}};
2 - Dimension Value: {{stay}};
3 - Dimension Value: {{date}};
Related
We have GA4 Enhanced Ecommerce working via GTM on our website. We are tracking all events mentioned in Google's documentation (e.g add_to_cart, begin_checkout, view_item_list).
With events such as 'view_item_list', 'begin_checkout' and 'purchase', we can see them in both 'Realtime' and the GA DebugView (they even show the 'Items' tab with all items within these events), and our dataLayer has no issues:
But when we try to view any of this data in Engagement > Events > 'view_item_list' (for example), the only data displayed is the standard Event Count:
As you can see from the screenshot, there are no parameters for 'view_item_list'. We are not sure how to get the actual data such as 'item_name' or 'item_list_name' to display.
Any help is much appreciated.
Thanks!
Edit:
We have now added these item-scoped parameters as custom dimensions:
However, it's been over 36 hours since we added these, some of these dimensions/parameters have generated cards but nothing is being generated by the 'Items' parameter.
Any help is still much appreciated. Thanks.
Item Names should be available in the "Ecommerce purchases" Report. You do not need to register the parameter as a custom definition for the "item_name" parameter. For example if you upload the "purchase" event in this example, then the item_name of 'jeggings' will be available in the Ecommerce purchases report:
What do you see in the Ecommerce purchases report?
I can't seem to get the datalayer variable to populate with a value. Unclear of what I've not done correctly.
I've set up a custom dimension, with index 9, in Google Analytics(GA), and I've got an ecommerce trigger which fires in Google Tag Manager(GTM) set up.
In GTM I've created a data layer variable, called checkoutStep, which has a Data Layer Variable Name 'step', and in the ecommerce tag I've got the custom dimension mapping for index set to '9' and value set to {{checkoutStep}}.
To be consistent with GTM setup I am trying to leverage the data layer.
I can see we already have a data layer push happening:
dataLayer.push({
'checkoutOption': checkoutOption,
'event': 'EECcheckoutOption',
'ecommerce': {
'checkout_option': {
'actionField': {'step': 3, 'option': checkoutOption}
I was assuming that that once on the checkout page, that the 'step' value of 3 would get pushed into the datalayer variable, but when I preview the tag properties I see that the custom dimenions 9 is 'undefined' instead of 3.
Have you used 'step' as dataLayer variable name, or the full reference in the ecommerce object, which would be 'ecommerce.checkout_option.actionField.step'? According to your code, this latter should be used to access the step value within the dataLayer.
Say my URL is in the format of www.mywebsite.com/search?keywords=library.
Aside from using Page Level 1 or Page Level 2, is there any way I could specifically get the value of a certain GET variable to be the column of my Google Analytics table?
I currently have this table (see below), but I'm using a Page Level column which I think is kind of a cheat. I'd prefer if there was a method to just pull through a specific section of the URL.
Is there a way to do this?
You can create a custom dimension in analytics. Go to your property settings -> custom definitions -> custom dimensions -> new. Give it a name (that will appear as column label in your reports). Since the keyword is part of the url hit level scope seems the best fit (meaning that your dimension is associated with a specific user interaction - you could also choose to tie it to the complete session).
If you create the custom dimension it will have a numeric index which you use in your tracking code together with the "dimension" keyword. The following example assumes you have created your first dimension (index 1) and are using php:
ga('send', 'pageview', {
'dimension1': "<?php echo filter_input(INPUT_GET, 'keywords', FILTER_SANITIZE_ENCODED); ?>"
});
(you can use another/better filter but do not put the variable directly into your page).
Now the value is send along with the pageview. Custom dimension do not show up in the standard reports, but you can use them in custom reports or set them as secondary dimensions in your standard reports.
I have a site with a store search that posts in the following format.
www.site.com/store-locator?city=&province=&zip[postal_code]=68123
I am trying to configure GA to give me feedback on people visiting this page and a count of specific zips searched.
example report data
/store-locator?city=&province=&zip[postal_code]=68123 1000 visits
/store-locator?city=&province=&zip[postal_code]=68456 768 visits
/store-locator?city=&province=&zip[postal_code]=68789 221 visits
note: the 'city' and 'province' values may also be populated (and I will want to mod GA to give similar data on these too).
Can anyone give feedback on how to configure GA to give me data similar to this?
Thanks!
As far as I know, the only way to look at this type of segment historically is using individual segments, which doesn't work well for an arbitrary number of zip codes. However, you can collect this data more effectively as described for new traffic. This comes up often with information like categories, tags, dates, query string variables, etc.
You can create Segments for each zip. This will work for historical analysis, but is impractical beyond a few. https://support.google.com/analytics/answer/3124493?hl=en&ref_topic=3123779
You can also use Content Grouping to create groups. This will not work historically. https://support.google.com/analytics/answer/2853423
The way I've handled this is using Custom Dimensions, which replaced Custom Variables when Universal came out. This also only works for future data.
To use Custom Dimensions, you would pass the zip code to google analytics explicitly when calling the analytics javascript code.
You can pull querystrings with javascript, or echo the parameter using something like PHP as follows:
<?php
if (array_key_exists("zip",$_GET)) { $theZip = $_GET["zip"]; }
else { $theZip = "nozip"; }
?>
And, sending the custom dimension --
ga('create', 'UA-XXXXX');
ga('set', {'dimension1': '<?php echo $theZip; ?>'})
ga('send', 'pageview');
You also need to setup the custom dimension in the Analytics Profile. Docs on custom dimensions https://developers.google.com/analytics/devguides/platform/customdimsmets
/store-locator?city=&province=&zip[postal_code]=68123 1000 visits
Step 1: In GTM, create a new macro. I called mine {{province}}
Macto Type = URL
Component Type = Query
Query Key = province
This will populate the Macro with the value of province from the query string.
Step 2: In your Google Analytics property, define a custom dimension called "province". This will assign an index key to the dimension.
Step 3: In your GTM tag for Google Analytics, you will find Custom Dimensions under more settings. Add a new dimension, apply the index number from #2 and for the dimension select the macro you created from #1
Publish and you are all set.
Now when you look in Google Analytics, you can add a secondary dimension and choose your newly created custom dimension.
Trying to figure out "how many users logged-in last month?" on my website using Google Analytics' web-interface (or API).
For each request, I'm sending user id's in a custom variable as the value:
_gaq.push(['_setCustomVar', 2, 'user_id', '#{ current_user ? current_user.id : 0 }']);
How can I get the number of unique user id's for all pageviews within a certain time-range?
Create a custom segment[*] that includes only visitors with your custom var set. Apply the segment and the audience overview tab will display your desired numbers.
[*] Advanced segments->create custom segment -> first dropdown to "include", second to "Custom Variable 2", third "Exactly matching" and the textfield gets the value for logged-in visitors
Sadly not possible in Google Analytics.
But you can do this in Google Data Studio. There you can create Dashboards for Google Analytics and create a new calculated field, like: COUNT(User ID)