Cloud Mode
Detailed technical documentation on sending events to Google Analytics 4 using the RudderStack Cloud mode.
RudderStack lets you send your event data to Google Analytics 4 via the cloud mode.
Find the open source transformer code for this destination in the GitHub repository.
Track
The track
call lets you capture user events along with the properties associated with them.
RudderStack supports both the gtag
and firebase
ways for tagging in websites in the cloud mode. However, note that:
If you use
gtag
, passing theclient_id
parameter is mandatory.If you use
firebase
, passing theapp_instance_id
parameter is mandatory.
Refer to the Google Analytics 4 Measurement Protocol guide for more information.
The mappings for the above parameters are listed in the following table:
Parameters | Mapping value |
---|---|
|
|
| from |
Refer to the FAQ section for more information on how to obtain the app_instance_id
.
A sample track
call using gtag
is shown below:
A sample track
call using firebase
is shown below:
Page
The page
call lets you record your website's page views with any additional relevant information about the viewed page.
RudderStack maps the page
call to a page_view
event by default, and passes it to Google Analytics 4 as a custom event.
As mentioned in the track
section above, the RudderStack cloud mode supports both the gtag
and firebase
methods for tagging in websites.
A sample page
call using gtag
is shown below:
A sample page
call using firebase
is shown below:
E-commerce
RudderStack supports e-commerce tracking for Google Analytics 4. You can refer to the RudderStack E-commerce Specification guide for sending events while instrumenting your site with the RudderStack SDK.
The following table lists the mappings between the RudderStack and Google Analytics 4 events:
RudderStack event | Google Analytics 4 event |
---|---|
Products Searched |
|
Product List Viewed Product Clicked |
|
Promotion Viewed Promotion Clicked |
|
Product Viewed Product Added Product Removed Cart Viewed Product Added to Wishlist |
|
Checkout Started |
|
Order Completed Order Refunded |
|
Product Shared Cart Shared |
|
Group |
|
Payment Info Entered |
|
The mapping of the Payment Info Entered event to the add_payment_info
or add_shipping_info
event is determined on the basis of parameters passed to it as explained here.
The following table lists the RudderStack and Google Analytics 4 properties mappings based on the specific RudderStack events:
RudderStack event | RudderStack property | Google Analytics 4 property |
---|---|---|
Products Searched |
|
|
Product List Viewed Product Clicked |
|
|
Promotion Viewed Promotion Clicked |
|
|
Product Viewed Product Added Product Removed Cart Viewed Product Added to Wishlist |
|
|
Checkout Started |
|
|
Order Completed Order Refunded |
|
|
Product Shared Cart Shared |
|
|
Group |
|
|
Payment Info Entered |
|
|
Payment Info Entered |
|
|
The Payment Info Entered event is mapped on the basis of parameters passed to it:
If
payment_method
is passed along with the other fields, it maps toadd_payment_info
event.If
shipping_method
is passed along with the other fields, it maps toadd_shipping_info
event.
Most of the above mentioned events include items
parameter which accepts an Item
array. The below table details out the common mappings for Items
array:
RudderStack | Google Analytics 4 |
---|---|
properties.products.$.product_id |
|
properties.products.$.name |
|
properties.products.$.coupon |
|
properties.products.$.price |
|
properties.products.$.position |
|
properties.products.$.category |
|
properties.products.$.brand |
|
properties.products.$.variant |
|
properties.products.$.quantity |
|
The below mentioned e-commerce events include items
parameter which accepts an Item
array.
RudderStack | Presence of |
Product List Viewed | Required |
Product Clicked | Required |
Product Viewed | Required |
Product Added | Required |
Product removed | Required |
Cart Viewed | Required |
Checkout Started | Required |
Payment Info entered | Required |
Order Completed | Required |
Order Refunded | Optional |
Product Added to Wishlist | Required |
View Search Results | Optional |
The following table details the parameter mappings present in the Items
array, for the above events:
RudderStack | Google Analytics 4 |
---|---|
properties.products.$.affiliation |
|
properties.products.$.currency |
|
properties.products.$.discount |
|
properties.products.$.item_category2 |
|
properties.products.$.item_category3 |
|
properties.products.$.item_category4 |
|
properties.products.$.item_category5 |
|
properties.products.$.item_list_id |
|
properties.products.$.item_list_name |
|
properties.products.$.location_id |
|
The below mentioned e-commerce events include items
parameter which accepts an Item
array.
RudderStack | Presence of |
Promotion Viewed | Required |
Promotion Clicked | Optional |
The following table details the parameter mappings present in the Items
array, for the above events:
RudderStack | Google Analytics 4 |
---|---|
properties.products.$.affiliation |
|
properties.products.$.creative_name |
|
properties.products.$.creative_slot |
|
properties.products.$.currency |
|
properties.products.$.discount |
|
properties.products.$.item_category2 |
|
properties.products.$.item_category3 |
|
properties.products.$.item_category4 |
|
properties.products.$.item_category5 |
|
properties.products.$.item_list_id |
|
properties.products.$.item_list_name |
|
properties.products.$.location_id |
|
properties.products.$.promotion_id |
|
properties.products.$.promotion_name |
|
Non e-commerce events
The below table lists the mappings of the non e-commerce track
events and properties that are passed to Google Analytics 4 events and properties:
Event Mapping | Property Mapping | ||
---|---|---|---|
RudderStack | Google Analytics 4 | RudderStack | Google Analytics 4 |
earn_virtual_currency |
|
|
|
generate_lead |
|
|
|
level_up |
|
|
|
login |
|
|
|
post_score |
|
|
|
select_content |
|
|
|
sign_up |
|
|
|
spend_virtual_currency |
|
|
|
tutorial_begin |
| - | - |
tutorial_complete |
| - | - |
unlock_achievement |
|
|
|
view_search_results |
|
|
|
You can pass the custom user properties to any of the events by passing them as properties.user_properties
. Refer to the Google Analytics 4 documentation for more information.
Rules for naming custom events
You must follow the below rules while choosing a name for the custom events:
Event names are case sensitive. For example,
my_event
andMy_Event
are two distinct events.Event names must start with a letter. Only letters, numbers, and underscores are permitted. DO NOT use spaces.
Do not use reserved prefixes and event names. Refer to the FAQ section to know more about the reserved event names and prefixes.
FAQ
What are the reserved prefixes in Google Analytics 4?
The reserved prefixes in Google Analytics 4 cannot be used for custom events. The list of such prefixes is mentioned below:
_ (underscore)
firebase_
ga_
google_
gtag.
Refer to the GA4 document for more information.
What are the reserved event, parameter, and user property names in Google Analytics 4?
Google Analytics 4 has some reserved event, parameter, and user property names that cannot be used. Refer to the Measurement Protocol (Google Analytics 4) guide for a complete list of reserved names.
How do I obtain the app_instance_id
?
app_instance_id
?You can retrieve the app_instance_id
through the Firebase SDK depending on the platform where the SDK is installed:
Contact us
For queries on any of the sections covered in this guide, you can contact us or start a conversation in our Slack community.
Last updated