• Модуль интеграций
  • Сообщество
  • Блог
Документация
Плагины и интеграцииВсе расширения для Medusa от сообществаСтартерыЗапускайте проекты быстрее с готовыми решениями
ЭкспертыПодберите специалиста для разработки и развития вашего проекта на MedusaКейсыПосмотрите примеры Medusa в продакшене и успешные внедрения
Представляем готовый к продакшену Medusa DTC Starter от Gorgo

26 августа 2026 г. · Продукт

Gorgo снижает затраты на адаптацию Medusa к локальным рынкам.

Мы разрабатываем плагины интеграции, осуществляем поддержку и развиваем сообщество разработчиков на Medusa в Telegram.

  • Ресурсы Medusa
  • Плагины и интеграции
  • Модуль интеграций
  • Стартеры
  • Эксперты
  • Кейсы
  • Medusa Чат в Telegram
  • Medusa Новости в Telegram
  • Документация Gorgo
  • Связаться с нами
  • TelegramGitHub
Плагины
Google Analytics logo

Google Analytics

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

npm install @variablevic/google-analytics-medusa
Категория
Аналитика
Создано
Variable Vic
Версия
0.1.1
Последнее обновление
11 месяцев назад
Ежемесячные загрузки
Загрузка данных
Звезды на Github
0
npmNPM

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.

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

  • Medusa backend
  • Google Analytics 4 property
  • GA4 Measurement ID
  • GA4 API Secret

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

Еще в этой категории

Посмотреть все
Аналитика
Bloomreach logo

Bloomreach

От Igor Ludgero Miura

Отправляйте уведомления и отслеживайте вовлечённость

Загрузка данных
GitHubnpm
Аналитика
K

Klaviyo

От Oak-digital

Плагин Medusa v2 для отслеживания событий и подписок в Klaviyo.

Загрузка данных
npm

Еще от этого автора

Посмотреть все
Платежи
Mollie logo

Mollie

От Variable Vic

Легко принимайте мультивалютные платежи через Mollie

Загрузка данных
GitHubnpm
yarn add @variablevic/google-analytics-medusa
1import { defineConfig } from "@medusajs/utils";
2
3// ... other imports and environment variables
4
5export default defineConfig({
6 // ... other configurations
7 plugins: [
8 // ... other plugins
9 {
10 resolve: "@variablevic/google-analytics-medusa",
11 options: {
12 measurementId: "G-XXXXXXXX", // Your GA4 Measurement ID
13 apiSecret: "XXXXXXXXXX", // Your GA4 API Secret
14 debug: false, // Optional, enables debug mode - no events will be sent to your property when debug is active!
15 },
16 },
17 ],
18});
1export const getGaClientId = async (): Promise<string | null> => {
2 const cookies = await nextCookies();
3 const gaClientIdCookie = cookies.get("_ga")?.value;
4
5 const gaClientId = (gaClientIdCookie as string)
6 .split(".")
7 .slice(-2)
8 .join(".");
9
10 return gaClientId;
11};
1const gaClientId = await getGaClientId();
2
3const body = {
4 region_id: region.id,
5} as Record<string, any>;
6
7if (gaClientId) {
8 body.metadata = {
9 ga_client_id: gaClientId,
10 };
11}
12
13const cartResp = await sdk.store.cart.create(body, {}, headers);