Вышел Модуль интеграций 2.0 для MedusaЧитать анонс
Google Analytics logo

Google Analytics

Отслеживайте e-commerce события заказов и корзины

npm install @variablevic/google-analytics-medusa
Категория
Создано
Регионы
Во всех регионах
Сервис
Версия
0.1.1
Последнее обновление
1 год назад
Ежемесячные загрузки
Загрузка данных

Medusa GA4 Plugin

A Google Analytics 4 plugin for Medusa that automatically tracks ecommerce events on your backend using Measurement Protocol. This plugin implements server-side tracking for key ecommerce events in your Medusa store.

Follow @VariableVic Website LinkedIn

Features

The plugin automatically tracks the following GA4 ecommerce events:

  • - When items are added to a cart
  • - When items are removed from a cart
  • - When shipping information is added to a cart
  • - When payment information is added
  • - When an order is placed

Prerequisites

Installation

Configuration

Add the plugin to your :

Client-Side Setup

This plugin handles server-side events, but some GA4 ecommerce events need to be implemented on the client side due to their nature:

  • - Product views
  • - Checkout initiation
  • - User registration
  • - User login

Additionally, to properly associate events with users, you need to set the GA client ID as metadata when creating a cart. Here's how to do it in the Next.js Starter:

  1. Get the GA client ID from the cookie:
  1. Set the client ID as cart metadata during cart creation:

Events Data Format

The plugin automatically formats cart and order data according to GA4's ecommerce event specifications. Each event includes:

  • Currency code
  • Transaction value
  • Item-level details (name, variant, quantity, price)
  • Customer information when available

Development

  1. Clone this repository
  2. Install dependencies:
  3. Build the project:
  4. Test the plugin:

For local development and testing:

npx medusa plugin:develop

Contributing

Contributions are welcome! Please read our contributing guidelines before submitting a pull request.

License

MIT