Problem/Motivation
Setting up a custom dimension (one or more) causes two pageviews to be sent to Google Analytics for every hit. Two calls of gtag('config', '[GA_MEASUREMENT_ID]',...
are made, each registering a pageview in Google Analytics for the single page hit.
Symptoms include twice the traffic you're actually getting in GA reports, a 0% bounce rate, and even numbers for page traffic stats (since hits always come in pairs).
Steps to reproduce
1. Install module and configure it with a custom dimension.
2. View the source of a page and see that two calls of gtag('config', '[GA_MEASUREMENT_ID]',...
are made, each registering a pageview in Google Analytics for the single hit.
Proposed resolution
It appears the first gtag('config', '[GA_MEASUREMENT_ID]',...
call contains the regular GA config options, while the second gtag('config', '[GA_MEASUREMENT_ID]',...
call contains the custom dimension(s) in the form of a "custom_map". Ideally these are combined into a single gtag('config', '[GA_MEASUREMENT_ID]',...
call instead of two.
Remaining tasks
Patch + review.
Original issue summary by vignot'
Subject: Custom dimensions make rebound drop
Hi,
I have a website running for almost 2 years with a rebound at about 50%.
I recently discovered I could add custom dimensions to see for exemple page views by node categories.
So I've created a custom dimension Category un GA admin UI.
I've added this dimension in module UI using a token as value.
Now, in GA when I create a report using my custom dimension Category, I can see all my categories with number of visitors by page views stick to zero.
Additionnaly, my rebound rate has dropped to almost zero !
This clearly hapenned at the exact time I setup the dimension and stopped when I disabled everything.
What did I miss ?
Thanks