Google Analytics Medusa
A Medusa plugin for sending ecommerce spec events to Google Analytics using the Measurement Protocol.
Features
- Server-side Event Tracking: Track key ecommerce activities from the backend
- Cart Operations: Monitor add to cart, remove from cart events
- Shipping & Payment: Track shipping and payment information updates
- Purchase Completion: Track completed purchases
- GA4 Integration: Built for Google Analytics 4 properties
Requirements
- GA4 property with Measurement ID
- API Secret credentials
- Medusa v2
Installation
npm install @variablevic/google-analytics-medusa
Configuration
Add the plugin to your medusa-config.ts file with your GA4 credentials:
- Measurement ID
- API Secret
Important Notes
Client-side Events
Certain events require client-side implementation:
- Product views
- Checkout initiation
User Association
It’s recommended to set GA client IDs as cart metadata to properly associate events with users.
Events Tracked
- Add to cart
- Remove from cart
- Shipping information updates
- Payment information updates
- Purchase completion