Articles on: Widgets and integrations

Setting up Google Analytics

This guide will take you through the process of setting up Google Analytics and setting up custom events that are not automatically tracked.

Setting up Google Analytics



Step 1: Create a Google Analytics 4 Property



Visit the Google Analytics website and sign in with your Google account.

Click on Admin in the bottom left corner.



In the Property column, click on "Create Property".



Provide a name for your property and select the appropriate time zone and currency. Click "Next".

Select your industry category and business size. Click "Next".

Choose your business objectives. Click "Create".


Step 2: Set Up Data Streams



Add a data stream

You can continue setting Data Streams right after "Create property", kindly select "Web"

Or in "Admin" in the Property column, click "Data Streams".



Click "Web".



Enter the URL of your website, and a Stream name.



You can choose to enable or disable enhanced measurement, which automatically captures page views and other events. After creating the data stream, you have the flexibility to disable specific enhanced measurement events if desired. It is advisable to enable enhanced measurement during the initial setup process. Click "Create stream".


Step 3: Install the Tracking Code on your website



Navigate to the Admin and at the top of the Property column, choose your desired property. Click on "Data streams" and select the data stream associated with your website.



Under Google tag, click "View tag instructions".



On the Installation instructions page, select Install manually. Copy provided code snippet.



Go to your Unicorn Platform account and navigate to the General settings > Global <head> HTML code paste copied code and hit the save button.



Please note that it may take up to 30 minutes for data collection to begin. You can then use the Realtime report to verify that you're receiving data.





Setting up custom event tracking in Google Analytics using Google Tag Manager



Step 1: Install Google Tag Manager on your website



Create an account with Google Tag Manager.



Setup container, choose "Web" then click "Create".



Install Google Tag Manager on your website. In your container, click "Install Google Tag Manager".



Copy the provided code from the top box.



Go to your Unicorn Platform account and navigate to the General settings > Global <head> HTML code paste copied code and hit the save button.



Copy the provided code from the bottom box.



Paste copied code in the Global <body> HTML code section and hit the save button.



Step 2: Setting Up Your Google Analytics 4 Tag in Google Tag Manager



In your Google Tag Manager container, create a new tag. Go to Tags Click "New".



Click Tag Configuration then choose the "Google Analytics: GA4 Event".

As Configuration tag select "None - Manually Set ID".

Input Your Measurement ID. To find it go to your Google Analytics, in the Admin, under your property elect the "Data Streams". Click the data stream for your domain. Here you will find your GA4 property's Measurement ID.



Input Event Name: test_event (can be any, but use this for now).



Click Triggering.



Create a New Trigger by clicking on the "+" sign in the upper right corner of the screen.



Click Trigger configuration.



Choose "Custom Event"



Specify the name of the Custom Event. For sample use test_event_trigger. Click "Save" and then give the Trigger name. You can give any name.



Step 3: Setting up event tracking in Unicorn Platform



For the Buttons - go to Unicorn Platform and paste this code snippet into the settings of the desired button > onclick field.

gtag('event', 'test_event_trigger');






For the Checkbox in the forms - go to Unicorn Platform and paste this code snippet into the settings of the desired checkbox> attributes field.

onchange="if (event.target.checked) {gtag('event', 'test_event_trigger')}"




Step 4: Checking if events are being tracked



In your Google Tag Manager click "Preview"



Enter your website URL and click "Connect". It will open your site in live and debug page.



Click the button where you placed the code in the onclick field a few times.

In Google Tag Manager Preview dashboard, you should see a list of fired triggers that fired GA4 events. It means that all's working and the events in GA are triggered.



When you are ready to publish your changes, click Submit.




That is it! Now your website is empowered with Google Analytics.

Updated on: 07/10/2024

Was this article helpful?

Share your feedback

Cancel

Thank you!