Im trying to extend Google Analytics 4 reports with data from the contact form submission.
Im sending event with a custom data through dataLayer to Google Tag Manager. Then GTM sends this to Google Analytics 4.
window.dataLayer.push({
event: 'formSubmission',
formData: {
lead_name: 'Lorem',
lead_email: 'lorem#ipsum.com',
lead_areas: ['web app design', 'mobile development']
}
});
I've correctly registered all custom dimensions and my data proceed correctly.
However, when im trying to create the report using lead_areas, Im facing a trouble that my areas listed as a string with comma-separated values instead of single values.
I don't have much experience in GA4. Please help me understand,
How can I send multiple values for one custom dimension in the scope of single event?
Thanks!
There are two type of custom parameters: text or number. So you can't send an array as value of a parameter but you can send different parameters like lead_area1, lead_area2, etc...
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}}
Im trying to extract parameters from the URL. Then send that data to google analytics via GTM. Using only one tag instead of having mulitple tags for each parameter.
website.com/index?searched=data%7Cdata%7Cdata
The data needs to be seperated. So I've created a variable that seperates each paramater.
function () {
var x = {{URL Query}}.split("|");
var z = x.slice(1, -1);
return z;
}
And a trigger that picks up on click.
I'm fairly new to google tag manager, and i'm unsure of the process to do this. Should I work with Datalayers or do a loop with Custom HTML tag? But then i'm not sure what the code is to send my data to google analytics.
What you need to do is to create multiple variables if you want to capture different parameters in the URL to separate dimensions in Google Analytics. When looking at your code I can see that you want to get the last value separated by "|". Take your code, place it within a "Custom Javascript" variable and then in your Google Analytics tag you can just map the variable to whatever dimension you have set up for this purpose.
Lastly, if you want to pick up more parameters in the URL, just create a a new Custom javascript variable, capture the parameter then map it to another dimension in the Google Analytics tag.
Hope this helps.
I want to get some server side error messages in google analytics using google tag manager. I managed to push some data in my dataLayer and I'm getting this:
dataLayer.push({
'event':'error_event_nl',
'eventCategory': 'errors',
'eventAction': 'starter_action',
'eventLabel': 'error-messages-label',
'error_messages_data':[
{
'original_message':'Server side error in English Version',
'translated_message':'Server side error inDutch Version'
}
]
});
My event is fired, see img:
and with data:
My question is how can i see in Google Analytics the value of the custom variable (from google tag manager) : errors_messagesData or from js script: error_messages_data ?
In google analytics I receive the values from eventCategory, eventAction and eventLabel. See img:
Thank you
Create 2 Data Layer Variables in GTM: error_messages_data.original_message and error_messages_data.translated_message.
And create 2 hit-level custom dimensions in GA, remember indexes.
Send these Data Layer Variables with events to GA using Custom Dimensions in tags:
Now you can add these dimensions to standard reports as a second dimension or use in custom reports.
Trying to extract a userID from GoogleAnalytics. This is to view which user is the using the website most and least.
I would to retrieve the top 5 user IDs and bottom 5 user IDs that were passed using either:
gtag('config', 'GA_TRACKING_ID', {
'user_id': 'USER_ID'
});
OR
using a custom dimension... ( https://support.google.com/analytics/answer/2709828?hl=en )
I'm (vaguely) aware of policies and TOS to keep 'non identifying' information on Google BUT there are posts online indicating you can link back to CMS data.
Steps so far
Google Analytics with UserID and view setup - Working in Google dashboard and showing filtered userID and All website data using the idea.
Requirements:
Extract page view and session data for each userId between a date
range (or all by default)
UserID via standard GA method
UserID via Custom dimension method
Any help, pointers or examples how someone has completed something like this are appreciated.
NOTE: This is to PULL data out of GA and manipulate/display it on an external system/dashboard.
Seen this which states it's not possible: Google analytics userID tracking
and this which states it (kind of) is google analytics API implementation for tracking a specific user activities in php
The solution I used:
Tracking
Create Google Analytics account
Create a new view by activating the UserID tracking (labeled NewView1)
Use https://developers.google.com/analytics/devguides/collection/gtagjs/custom-dims-mets
i.e. Define your custom dimension
Get Analytics tracking code + Add custom definition code
Create a Custom report using the 'metrics' you want to see and filtering by the 'custom dimension' I created earlier.
(note: data took ~ 12 hours to be visible so don't expect to work instantly)
Front end tracking additions
gtag('config', 'GA_TRACKING_ID', {
'custom_map': {'dimension<Index>': 'dimension_name'}
});
// Sends the custom dimension to Google Analytics.
gtag('event', 'any_event_name', {'dimension_name': dimension_value});
Extraction
Create New Google Developer Console Project (API)
Use a Service Account to connect the API with Analytics ( https://developers.google.com/analytics/devguides/reporting/core/v4/quickstart/service-php ) -- API -> credentials -> Create Credentials (Service Account key)
(assign role [mine was set to Project => View])
Save the Text file to your filesystem and rename to json as per examples
Add permissions to your Analytics project by copy/pasting the 'Email' from the Service account details into Analytics User Management.
Get the view ID of the data you wish to extract (Analtyics created in step 2 in tracking)
Use the sample Code (HelloAnalytics.php) to connect and extract data
Use your custom dimension to filter results
The dimension filter I used was $dimensions (see below)
...
$dimensions = new \Google_Service_AnalyticsReporting_Dimension();
$dimensions->setName('ga:dimension1'); // as per docs
// Create the ReportRequest object.
$request = new \Google_Service_AnalyticsReporting_ReportRequest();
$request->setViewId($VIEW_ID);
$request->setDateRanges($dateRange);
$request->setMetrics(array($sessions, $pageviews));
$request->setDimensions($dimensions);
From there I was able to see the same data via API that I could see in the custom report on analytics web.
NOTE: be careful of which Google project and view you're in while setting up
permissions and dimensions.
NOTE: using gtag() code and not Universal (ga()) js code
The answer is a very brief/rough summary of how I achieved my specific goal. It is not a one-size-fits all solution but hopefully it will give someone a better idea of how to set and extract custom variable data within Google.
The final result was data from the API. From there it's up to you.
Is it possible to push custom channel group into Google analytics in a similar way as events? For events I use this code:
_gaq.push(['_trackEvent', 'Popup - displayed', 'Popup displayed - Popup Id 5', 'This is popup title']);
Now I want to push new custom channel group Popup displayed each time user get served popup so I can compare results with Organic search without popup, Direct traffic without popup with organic search with popup.
I would like to accomplish something like this:
Tnx!
With the current Google Analytics version you could use a set call with your tracker object to overwrite campaign data and then create a custom channel definition that matches your custom data:
trackers = ga.getAll();
tracker = trackers[0];
tracker.set('campaignMedium', 'withPopup');
No idea how you would do this with your version of Analytics which is deprecated. Also this may have side effects (like loosing the original campaign data).
However you may simply create two segments, one for users who have seen the event and those who have not. Since you can select multiple segments this allows for a comparison without changing anything in the code.