Ultimate Guide to Google Analytics 4 Migration & Setup

Google Universal analytic would sunset very soon, but the fact can tell many users might still have some questions regarding settings in GA4. In this piece, I would walk through the must-have settings and answers some myth questions.

Google Universal analytic would sunset very soon, but the fact can tell many users might still have some questions regarding settings in GA4. In this piece, I would walk through the must-have settings and answers some myth questions.

Table of Contents: Ultimate Guide to Google Analytics 4 Migration & Setup

Existing UA Analytic Historical Data Backup

Most people are asking whether existing version UA historical data are importable to new GA4 or not directly using a click button. The answer is direct, which is NO!. The main reason is that the two tracking systems are deployed with totally different infrastructure and underlying data collection logic. Here are the key differences as follows:


  • Session-based or so-called cookies-based. It mainly relies on server side interaction with client side browsers to identify user identity.


  • Token-based/User ID-based, or so-called event-based. To identify users identity, it mainly relies on intrinsic data collection logic set by Google behind in the underlying infrastructure. Furthermore, it allows users to customize on top of that by setting events or importing users IDs. In an advanced model that GA4 allows, users can implement server to server to identify users using APIs. More details in measurement protocol and api section in a moment as follows.

In fact, token-based has already existed that was paralleled with cookies-based or even earlier. The reason why Google just shifted to token-based right after GDPR or CCPA regulation rather than implementing it before is because of cost and financial considerations. Cookies-based saved cost far away.

There are three ways to backup your UA historical dataset

  • Manually download
  • Export to Google Sheets
  • Fetch data using Google analytics API. For more details regarding Python script, please refer to this article

Chapter 20: Google Analytics 4 API Access Using Python to Integrate with your Custom Marketing Dashboard

Data stream & Site Connection

This part is the core section to integrate with GA4 and let Google know how many properties are sharing with these tags.

First thing first, we need to integrate GA4 with your apps or website by default options or manually

  • Default option, for example, sitekit for CMS users like WordPress
  • Manually. Copy and paste the tags from data stream section to your site between <head></head>

For manual deployment, please be sure to consider multi-sites or subdomain web structure and tell GA4 how many your tags are sharing with. This is for avoiding to separately create new tags and add tags to each site. We can just add the property ID to the very first tag you sign up for GA4. Here is the sample as follow

<!-- Google tag (gtag.js) -->

<script async src="https://www.googletagmanager.com/gtag/js?id=propertyA"></script>


  window.dataLayer = window.dataLayer || [];

  function gtag(){dataLayer.push(arguments);}

  gtag('js', new Date());

  gtag('config', 'propertyA');

  gtag('config', 'propertyB');

  gtag('config', 'propertyC');


Last but not least, as it requires the property ID, so you still need to create a new property for each specific subdomain site or subfolder path in GA4 if you like to track their performance independently in a separated dashboard.

Import Existing Settings to GA4

The other indispensable section, notably for marketing and business purpose is the existing integration and data library. Fortunately, we don’t have to set up all deployments such as conversion, audience libraries and segmentation and Google product integration from scratch. GA4 provides us with a feature called import from universal analytics. Here are more details as follows:

Conversion settings:

In GA4, conversion creation and settings are based on event-setting. This feature can automatically convert UA conversion into new GA4 settings. For more details regarding event and conversion creation, we would walk through in a moment.

Audience group

As well as the audience group, the audience library can be imported just clicking a button to GA4. Unfortunately, importing settings does not mean the size of the audience are kept in GA4. As mentioned earlier, the data size normally might be downsized or even start accumulating from scratch, unless you have deployed and used a 3rd party CDP and map UA data with user ID before…

Product links

Basically users would not only utilize one GA4. GA4 should collaborate with other marketing and data tools to meet the business purpose, such as Google ads, big query, etc. At least, every GA4 would connect with Google search console to grab the organic traffic insight.

Event & conversion creation and modification

The 3rd critical section in GA4 setup is event and conversion. It’s because if you like to optimize advertising and dynamic content much better, you need more audience data from events when we’re in the cookieless era, rather than just using the default existing events.

Being said that, as different business models such as ecommerce, SaaS, game app etc would have different needs to collect and process data, so here I would mainly walk through the skeleton logic of setting up events and creation in GA4.

Relationship between default events and new events in GA4

GA4 already has set up some fundamental events from top to low funnel. Moreover, until the moment I publish this guide, we need to leverage this set of existing events to create new events and specify conversions in GA4. This logic is critical and you will understand more in upcoming samples.

1. New Event Creation

In new event creation, there are two things we need to follow. One is to define the purpose of this new event using existing. For example, if this new event is to collect page view, we need to set up like this

  • Parameter: event_name
  • Value: page_view

Then, we need to add one more conditions with the firing destination of this new event name

For example, 

  • Parameter: page_path
  • Value: the specific web page path, such as /chapter-80-langchain-chat-ai-model-applied-in-ai-web-app-dapp-for-beginners/

2. Set up conversions

For the default existing events given by Google, you can just switch an option button straightforwardly. For new events, we need to add the new event name in the conversion section. Please be sure the conversion name is the same as the new event name if the new event is for tracking conversion purposes.

Measurement Protocol API

Regarding identifying users using specific ID beyond event settings in GA4, Google provides API options to interact with user databases directly, such as CRM or server side databases. So far, there are two options which respectively are firebase and gtag.js.

For the firebase option, users are required to set up a NON-SQL database in firebase or sync firebase with server side data. On the other hand, gtag.js can allow users to directly interact with GA4 and server side at the same time.

const measurementId = 'G-XXXXXXXXX';

const apiSecret = '<secret_value>';

function addCustomerTier(clientId, events) {

  // Request the customer tier from the CRM.

  const customerTier = getCustomerTier(appInstanceId);

  const queryParams = ?measurement_id=${measurementId}&amp;api_secret=${apiSecret};

  fetch(https://www.google-analytics.com/mp/collect${queryParams}, {

    method: "POST",

    body: JSON.stringify({

      "client_id": clientId,

      "user_properties": {

        "customer_tier": {

          "value": customerTier



      "events": JSON.parse(events)




The only thing we need to do in GA4 settings is to create an API key. Both property ID and API key are required on the app server side setting.

Big Query Data Import

If users have already store a bunch of user ID in big query SQL database, GA4 allows users to import IDs and update the audience library, which can be applied to analytics and advertising purposes.

Custom Report Dimension & Metrics

As well as UA, GA4 also provides report dimension and metric customization. The difference is all customisation report data that can be only accumulated and counted from the 1st date activation in GA4. So, it’s better to activate GA4 as early as possible, although UA is still running

Most Popular Google Analytics 4 Fundamental and Advanced Tutorial Recommendation

Before walking through the Google analytics setup details, here are fundamental and advanced Google Analytics couresa courses I think it is very helpful and useful.

  1. Google analytics 4 fundamental
  2. Google analytics 4 advanced

I hope you enjoy reading Ultimate Guide to Google Analytics 4 Migration & Setup. If you did, please support us by doing one of the things listed below, because it always helps out our channel.