pole
Home » Training » Adding Google Analytics Tracking Code

Adding Google Analytics Tracking Code To Your Website

Where / How; do visitors find their way to our website?

A great question – whilst not 100% perfect adding some tracking code to links is a good way of gathering data without relying on people’s memory and staff having to record something.

Eligible links include – your entry in the Google Business Profile so instead of being:-

https://yourcompany.co.uk

The link is

https://yourcomany.co.uk/?utm_source=google&utm_medium=organic&utm_campaign=gbp-profile

However, the user just sees the word Website

Beneath the surface is the code https://website-doctor.com//?utm_source=google&utm_medium=organic&utm_campaign=gbp-profile

Adding the UTM tracking code

https://ga-dev-tools.google/ga4/query-explorer/

Use this link to go to the page on the Google website where you can create a tracking code like this.

?utm_source=google&utm_medium=organic&utm_campaign=gbp-profile

and off course add the domain name in front of the code – if you do it then creates a link on the screen like the one below.

This video runs through how to create the URL correctly so it works well with Google Analytics.

The GA4 Query Explorer is a Google Dev Tools utility used to test and construct API calls for the Google Analytics Data API (v1).

When building or testing a report query in the tool, the typical parameters are split into core query inputs, filtering controls, and pagination settings:

1. Account & Property Parameters

  • Property ID: The numerical ID for the GA4 property (e.g., properties/123456789).

2. Time Parameters

  • Date Ranges (dateRanges): Defines the reporting window using start and end dates.
    • Start Date / End Date: Formatted as fixed calendar dates (YYYY-MM-DD) or relative terms like today, yesterday, 7daysAgo, or 30daysAgo.

3. Data Selection Parameters

  • Dimensions (dimensions): Qualitative attributes used to break down and group your data (e.g., date, sessionSource, pagePath, deviceCategory, country).
  • Metrics (metrics): Quantitative measurements calculated against your chosen dimensions (e.g., activeUsers, eventCount, conversions, sessions, bounceRate).

4. Filtering & Sorting Parameters

  • Dimension Filter (dimensionFilter): Restricts results based on specific dimension values (e.g., filtering pagePath to only include URLs containing /shop/).
  • Metric Filter (metricFilter): Restricts results based on metric threshold conditions (e.g., only showing rows where eventCount > 100).
  • Order By (orderBys): Specifies the sorting order of the output (ascending or descending) based on selected metrics or dimensions.

5. Pagination & Result Control

  • Limit (limit): The maximum number of data rows to return in a single response (e.g., 100 or 1000).
  • Offset (offset): The starting row index for pagination (used when pulling large datasets in batches).
  • Keep Empty Rows (keepEmptyRows): A boolean (true/false) that determines whether to display rows where metric values are zero or null.

The code can be used for a variety of jobs.

Send an email out with a link which says “Find Out More…” and when you click that it will use a link which not only goes to a particular page (or the home page) but it will also (if configured carry our tracking code which is then recorded by Google Analytics.)

Place to use:-

  • Email
  • QR codes on business cards
  • Leaflets / Adverts
viewing the results

Method A: Switch the Primary Dimension to Campaign

  1. Go to Reports > Acquisition > Traffic acquisition.
  2. Click the small drop-down arrow above the first column (where it currently says Session source / medium).
  3. Change it to Session campaign.
  4. Look for gbp-profile in the list.

Method B: Add a Secondary Dimension (Best View)

  1. Stay on the Traffic acquisition report (set to Session source / medium).
  2. Click the blue “+” icon next to the primary column header.
  3. Search for and select Traffic source > Session campaign.
  4. You will now see google / organic alongside gbp-profile on a single row.

4. How to verify it instantly (Real-Time Check)

To test it right now without waiting 24 hours for main reports:

  1. Open a new tab or use your mobile phone (disconnected from Wi-Fi).
  2. Search for the business on Google Maps and click the Website button.
  3. Open Google Analytics 4 > Reports > Realtime.
  4. Scroll down to the card titled “Event count by Campaign” or “Users by Session source / medium”.
  5. You should see your live visit pop up immediately under google / organic with campaign gbp-profile.

Click the gear icon for the relevant account and then select

Property Access Management

Add person

add the person

Add the person

5. Email which you have to accept

6 Features etc.

7. Stats

Tracking data