Google Analytics

How to setup and use GoogleAnalytics to track key events across your guides experience.

Overview

The following guide will outline the steps required to set up google analytics for use with Different Breed.

1. Create A Tracking Source Within Different Breed

You can find the location to define measurement tracking on Different Breed by accesing the following from your guides landing page: Metrics > Tracking. Once loaded, click Create Source, select Google Analytics or Google Adwords as the provider and follow the next steps.

2. Create a Google Analytics 4 property.

Different Breed is unable to assist with setting up your Google Analytics property. If you need help with this step, follow these steps from Google’s Help Center.

3. Copy your measurement ID.

For websites, a Measurement ID can be used to send data to your Google Analytics 4 property through an associated web data stream (similar to a Tracking ID in Universal Analytics properties). Find your Measurement ID in Admin > Data Streams.

Once found, past the value into the "Measurement ID" field.

NOTE: If you’re still using Universal Google Analytics, you will need to upgrade to Google Analytics v4 to enable tracking on Different Breed.

4. Create your measurement protocol secret

To create a new secret, navigate in the Google Analytics UI to: Admin > Data Streams > choose your stream > Measurement Protocol > Create

Once created copy the secret value and paste it into the "Measurement Secret" field.

5. Select Events To Track

On the Different Breed Tracking source form you are presented with a number of events and page views you can track. While the majority of these are standard events and do not require additional set up, a few will require custom events to be created to get the most of our your reports.

Standard Events

Custom Events

To create a new custom event, navigate in the Google Analytics UI to: Admin > Data Streams > choose your stream > Measurement Protocol > Create

6. Save Your Tracking Source

Once you have selected your desired events, simply save the source and the tracking events will begin to fire.


Test Your Tracking Source

To test your tracking pixel, Simply view the Real Time Reporting view within your Google Analytics UI. Once you have the real time reporting view loaded, navigate your guide and trigger the enabled events to see them appear in the UI.


Breakdown Of Events We Send

User Data

All the events we send will contain the following user data.

Payload Sent
type GA4UserData = {
  user_agent: string;
  client_ip: string;
  client_id: string;
  gclid: string;
  engagement_time_msec: number;
};

For the purpose of having the active users logged, we set engagement_time_msec to 1 in every tracking event we send.

Event Structure

All the events we send to Google Analytics contain the following structure and properties:

Page View

Tracks a customer landing on a desired page during the guides experience. The following pages are supported:

  • Guide Filters

  • Guide Content

For each page view you enable we will send the following data structure to Google Analytics:

Payload Sent
export type GA4PageViewPayload = {
  client_id: string;
  events: {
    name: 'page_view';
    params: GA4UserData & {
      page_location: string;
      page_title: string;
      db_guide_id: string;
    };
  }[];
};

Campaign

Tracks a traditional utm style campaign. To track this effectively your URL parameters should be formatted in the following way:

?utm_source=hubspot&utm_medium=email&utm_campaign=spring_sale&utm_id=campID&utm_term=term1%2C+term2&utm_content=content_xyz

Google have a useful tool to help with this: https://ga-dev-tools.google/ga4/campaign-url-builder/

This will enable us to send the following data structure to Google Analytics:

Payload Sent
export type CampaignData = {
  campaign_id: string;
  campaign: string | null;
  source: string | null;
  medium: string | null;
  term: string | null;
  content: string | null;
};

export type GA4CampaignPayload = {
  client_id: string;
  events: {
    name: 'campaign';
    params: GA4UserData &
      CampaignData & {
        page_location: string;
        page_title: string;
        db_guide_id: string;
      };
  }[];
};

Filters Applied

Tracks when a user applies filters to the guide.

Payload Sent
export type GA4FiltersAppliedPayload = {
  client_id: string;
  events: {
    name: 'guide_filters_applied';
    params: GA4UserData & {
      ticket_puchased: boolean;
      visual_impairments: boolean;
      hearing_impairments: boolean;
      mobility_physical_disabilities: boolean;
      chronic_illnesses_fatigue: boolean;
      mental_health_emotional: boolean;
      speech_communication: boolean;
      neurodivergent_sensory: boolean;
      cognitive_disabilities: boolean;
      page_location: string;
      page_title: string;
      db_guide_id: string;
    };
  }[];
};

Share Clicked

Tracks when a user clicks to share the guide.

Payload Sent
export type GA4GuideShareClickedPayload = {
  client_id: string;
  events: {
    name: 'guide_share_clicked';
    params: GA4UserData & {
      page_location: string;
      page_title: string;
      db_guide_id: string;
    };
  }[];
};

Send the Event Structure only.

Tracks when a user clicks to print the guide.

Payload Sent
export type GA4GuidePrintClickedPayload = {
  client_id: string;
  events: {
    name: 'guide_share_clicked';
    params: GA4UserData & {
      page_location: string;
      page_title: string;
      db_guide_id: string;
    };
  }[];
};

Send the Event Structure only.

Feedback Initiated

Tracks when a user clicks to provide feedback on the guide.

Payload Sent
export type GA4GuideFeedbackInitiatedPayload = {
  client_id: string;
  events: {
    name: 'guide_share_clicked';
    params: GA4UserData & {
      page_location: string;
      page_title: string;
      db_guide_id: string;
    };
  }[];
};

Send the Event Structure only.

Feedback Submitted

Tracks when a user clicks to submit feedback on the guide.

Payload Sent
export type GA4GuideFeedbackSubmittedPayload = {
  client_id: string;
  events: {
    name: 'guide_share_clicked';
    params: GA4UserData & {
      page_location: string;
      page_title: string;
      db_guide_id: string;
    };
  }[];
};

Send the Event Structure only.

Last updated