Google Analytics
Google Analytics is the leading analytics platform by Google, now at the edge.
Find it on GitHub: /edgee-cloud/ga-component
Google Analytics 4 is now available at the edge. This means you can use Google Analytics 4 without having to load the Google Analytics 4 script on your website. This is a huge win for privacy and performance.
Google Analytics component accepts page
, identify
, and track
events.
Getting Started
Google Analytics 4 supports server-to-server integration via its Measurement Protocol API. Edgee monitors the capabilities of the Measurement Protocol API and regularly updates the GA component to propose the best level of reporting.
To add Google Analytics to your project:
- From the Edgee console, go to your project and go to the Data Collection service.
- Click on “Add Destination” and choose “Google Analytics”.
- Enter the
Measurement ID
and theAPI Secret
associated with your GA4 stream and click Save.
(To create a new API Secret, navigate in the Google Analytics UI to Admin > Data Streams > choose your stream > Measurement Protocol > Create) - You can now start sending events to Google Analytics.
Destination name
When specifying the destination in the Edgee Data Layer or using SDK methods, please use google_analytics
as the component name.
How to measure ecommerce events with Google Analytics component
The Google Analytics component supports all standard GA4 ecommerce events. Here’s how to implement ecommerce tracking using the Edgee Data Layer:
With the Edgee Data Layer
To track ecommerce events from the edge, add them to your Edgee Data Layer like this:
With the Edgee SDK
If you want to track ecommerce events from the client, you can use the Edgee SDK.
Supported Ecommerce Events
The component supports all standard GA4 ecommerce events:
-
View Item List & Selection
view_item_list
: When displaying a list of productsselect_item
: When a user clicks on a product in a list
-
Product Views & Cart Actions
view_item
: When a user views product detailsadd_to_cart
: When adding items to cartremove_from_cart
: When removing items from cartview_cart
: When viewing the shopping cartadd_to_wishlist
: When adding items to a wishlist
-
Checkout Process
begin_checkout
: Start of checkout processadd_shipping_info
: When shipping information is addedadd_payment_info
: When payment information is added
-
Purchase & Refund
purchase
: When a transaction is completedrefund
: When a refund is issued
-
Promotions
view_promotion
: When a promotion is viewedselect_promotion
: When a promotion is clicked
Don’t forget to use a track
event, with the name
property set to the event name.
For example, to track a purchase
event, you need to use a track
event with the name
property set to purchase
.
Properties
Each ecommerce event requires specific parameters. Use the properties
object to pass the parameters to Google Analytics.
currency
: The currency code (e.g., “USD”)value
: The monetary value of the transactiontransaction_id
: The transaction IDtax
: The tax amountshipping
: The shipping amountcoupon
: The coupon codeproducts
: Array of products with these key properties:sku
: Product SKUname
: Product nameaffiliation
: Product affiliationcoupon
: Product coupondiscount
: Product discountindex
: Product indexbrand
: Product brandcategory
: Product categorycategory2
: Product category 2category3
: Product category 3category4
: Product category 4category5
: Product category 5list_id
: Product list IDlist_name
: Product list namevariant
: Product variantlocation_id
: Product location IDprice
: Product pricequantity
: Number of items
Create product-scoped custom parameters
You can define custom product parameters by simply adding them to a product
object.
example:
Example: Complete Purchase Event
Here’s a complete purchase event example:
Remember to:
- Include all relevant item parameters for better reporting
- Set the correct currency code when sending monetary values
- Use consistent product identifiers across all events
- Keep product names and categories consistent
For more details on GA4 ecommerce implementation, refer to the official Google Analytics documentation.