Google Analytics: Session-scope custom dimensions - google-analytics

What happens when you set a session-scope custom dimension more than once in the same session?
Simple question for ya.
EDIT: In case it wasn't clear... suppose you have a session-scope custom dimension, defined by:
name: my_custom_dimension
index: 1
scope: Session
and then do
ga('set', 'dimension1', 'LOL');
and then in the same session do
ga('set', 'dimension1', 'LMAO');
what will the reports show is the value of dimension1 for that session?

Only the last value is applied to all the hits in the session:

Related

Which is the best method to set up event tracking for new account signup steps in GA4?

Currently I'm using the following analytics.js method to track different funnels/goals and these get triggered on each specific page.
ga('send', 'pageview', '/ConversionEvents/Step1_MembershipPlan');
ga('send', 'pageview', '/ConversionEvents/Step2_AccountInformation');
ga('send', 'pageview', '/ConversionEvents/Step3_PaymentInformation');
ga('send', 'pageview', '/ConversionEvents/Step4_AccountConfirmation');
ga('send', 'pageview', '/ConversionEvents/Step5_ThankYou');
However, now that I switched to gtag.js I'm seeing what the best method would be to set these up. I came up with the following 3 options.
Option 1:
gtag('event', 'sign_up', {'step_name': 'step1_membership_plan'});
Option 2:
gtag('event', 'pageview', {'step_name': 'step1_membership_plan'});
Option 3:
gtag('event', 'step1_membership_plan');
I'm leaning towards using option 3 because it would be easier to view these events in GA4 since it will be listed as a different event name and it would be easier to create funnels.
From reading online, they say it's better to use the recommended/automatic events like sign_up and pageview for this but I'm not sure if then I can set up events to track the different parameters (e.g. step_name) that I set up for each step.
Which option would be the best to go with?
Thank you!
Personally, I would not clutter my GA4 with too many distinct event names.
But that's a matter of taste: If I understand Google's limits page correctly, web properties do not currently have a limit on distinctly named events, whereas app properties are limited to 500.
Ref.: https://support.google.com/analytics/answer/9267744?hl=en)
Instead, I would send the following events:
sign_up, when a user has completed the registration, aka visits the thank you page.
sign_up_step_complete, when a user has completed a step in the registration process. Sending the custom dimension step_name for each step.
(That is assuming that each step is just a virtual page view and does not actually send a page_view event to Google. If it does send a page_view, you can create the sign_up_step_complete event server-side based on the URL or not create an event at all and just use the page_view.)
This way, you're using the dafault sign_up event which might show up in a default GA report while also tracking intermediate steps in a separate custom event.
Finally, I would visualize the data in a free-form exploration funnel analysis.

Custom Dimension doesn't show up in Google Analytics

I have the following custom dimension parameter that I'm sending on page view:
ga('send', 'pageview', { 'environment': 'DEV' });
(DEV changes depending on the website environment)
I logged into Google Analytics => Admin => Custom Definitions/Custom Dimensions, then "New Custom Dimension" and added "environment", Scope = Hit.
I created a custom report that included Pageviews as the Metric and "environment" as the Dimension and I don't see any information for the custom dimension I added. The js has been in there for several weeks (throughout our development cycle) so I would expect to see some information.
Am I missing a step somewhere?
Bear with me if I'm calling something by the wrong name, I'm relatively new to Google Analytics.
Thanks
JH
The custom dimensions are set by number, what you have named them in the GA interface shouldn't appear in the code. So for your example you'd have
ga('send', 'pageview', {
'dimensionX': 'DEV'
});
where X is the number of the dimension you wish to set.

Google Analytics hits going to account, not property

I'm sending hits to my GA Property tracking ID, but it is always going to the first property (UA-nnnnnn-1) instead of the hit going to the tracking ID for the specific property I specified (UI-nnnnnnn-3).
Is it possible to send it to a specific property within an account?
Note: I'm testing out with Real Time.
Here is code:
console.log("Set up Google Analytics: AnalyticsId =", googleAnalyticsId)
ga('create', googleAnalyticsId, 'auto', {
'storage': 'none',
'clientId': sha
});
...
ga('send', 'pageview', '/test');
The hit is going to a different ID (UA-nnnnnn-1) than specified and seen in my console.log statement (UA-nnnnnn-3).

What is the correct syntax to set a custom dimension in Google Analytics?

I'd like to send some custom dimensions back to GA with every blog post that is read on my website - author and category.
When I set up the custom dimensions in GA I got this code to use:
var dimensionValue = 'SOME_DIMENSION_VALUE';
ga('set', 'dimension2', dimensionValue);
However, in the GA docs it specifies a different syntax using "send" rather than "set".
https://developers.google.com/analytics/devguides/collection/analyticsjs/custom-dims-mets
ga('send', 'pageview', { 'dimension4': '<?=$categories?>'});
We are using universal google analytics, but this conflicting information means I'm not sure which syntax to use.
Thanks in advance
The first code block is how you set the custom dimension (CD) that can be sent with any hit: event, pageview, transaction, etc.
The second code block is how you set the CD and send it with a pageview. So it's a specific example of the first method.
Both are valid, it's just that the second example is more complete.
When sending data to CDs, don't forget to create and define them in the GA configuration as well.

CustomDimension send via ga('set',...)

I have two buttons, to set gender.
For each gender button I've set up a customDimension like ga('set', 'dimension1', 'male'); or ga('set', 'dimension1', 'female');
In the Javascript Console from FireBug I see that the ga() command is executed without errors. In GoogleAnalytics I have set a customDimension
Must I send this data specific via ga('send',...... or is this not needed??
If yes, which parameters do I have to set?
I can't see any received Data in GoogleAnalytics GUI and I have waited about 48 hours.
Custom Metrics and Dimensions must always be sent with an interaction hit, else they will not get recorded.
In addition, fields set with ga('set'... must be followed by an interaction hit - "set" in this case literally means "set this field for subsequent use in interaction hits". The difference between using set and passing the custom dimensions via the configuration object of an interaction hit (pageviews, events etc) is that "set" will affect all following hits while passing the custom dimension/metric as a parameter to a hit will only affect that specific hit.
So if you use ga('set', 'dimension1', 'male') and you have after that one pageview and two events the dimension will be recorded three times (not so much a problem with custom dimensions, potentially a big problem with custom metrics).
If you do instead:
ga('send', 'pageview', {
'dimension1': 'male'
});
the dimension will be send only once.
But no matter how you do it, the data will only be sent along hit data, so you need a pageview, event or transaction if you want any results.

Resources