How to add content group to Google Analytics
Step 1: Add code to web pages
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
topic: 'kubernetes',
});
// code snippet to install googletagmanager
Step 2: Create Variables
Variables tab:
New->Data Layer Variable-> Use the same key (e.g.topic) inData Layer Variable Namefield.New->Google Tag: Event Settings-> Usecontent_groupinEvent Parameterfield -> use the reference of theData Layer Variablein theValuefield.
Step 3: Create Triggers
The Message or the dataLayer push may happen after initialization, so we need to create a trigger that happens at a later stage, e.g. DOM Ready, Window Loaded.
New-> SelectDOM Readytype.
Step 4: Create Tags
New->Google Analytics->Google TagTag IDset toMeasurement ID(e.g.G-XXXXXXX)Shared event settings: setEvent Settings Variableto theGoogle Tag: Event Settingsset in Step 2.Triggerset to the trigger created in Step 3.
New->Google Analytics->Google Analytics: GA4 Event- set
Measurement ID(e.g.G-XXXXXXX) Event Parameters: setEvent Settings Variableto the one created in Step 2.
- set
Step 5: Preview and Submit
Check in preview, make sure the data is set in dataLayer and the tags are fired.
Recommended ReadingSponsored
How-to
How to add content group to Google Analytics
How To Integrate Google AdSense into Modern Web Apps (React & Next.js)
How To Export and Download HTML5 Canvas as an Image
How To Embed YouTube Videos Efficiently (Responsive, Fast & Privacy-Safe)
How to find all files containing a specific text
How To Host Static Websites On Amazon AWS EC2
How To Host Static Websites On Amazon AWS S3
How To Host Static Websites On GCP Cloud Storage
How to safely store API Keys
How to Speed Up IntelliJ IDEA / Clion
How-to Guides

