https://github.com/learn2torials/ecommerce-gtm
Enhanced Ecommerce For Google Tag Manager
https://github.com/learn2torials/ecommerce-gtm
ecommerce google gtm manager tag
Last synced: 26 days ago
JSON representation
Enhanced Ecommerce For Google Tag Manager
- Host: GitHub
- URL: https://github.com/learn2torials/ecommerce-gtm
- Owner: learn2torials
- License: mit
- Created: 2019-10-03T17:46:20.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T22:10:05.000Z (over 3 years ago)
- Last Synced: 2025-02-16T20:03:49.717Z (over 1 year ago)
- Topics: ecommerce, google, gtm, manager, tag
- Language: JavaScript
- Size: 334 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ecommerce-gtm
### Google Tag Manager Module for Enhanced Ecommerce
This is a Javascript module that implement Google Tag Manager for enahanced ecommerce. It is designed to use [GTM](https://developers.google.com/tag-manager/enhanced-ecommerce) snippet.
You can easily use custom dataLayer and additional events. You can use this library in any javascript framework for example:
- react
- angular
- vue etc..
## Installation
[npm](https://www.npmjs.com/):
```bash
npm install ecommerce-gtm --save
```
## Usage
Initializing GTM Module:
```js
import GTagManager from 'ecommerce-gtm'
# With default dataLayer
GTagManager.initialize({ id: "GTM-000000" });
# with custom data layer
GTagManager.initialize({ id: "GTM-000000", layer: "dataLayer2" });
```
## Enhanced Ecommerce
### Event example:
```js
import GTagManager from 'ecommerce-gtm'
# With default dataLayer
GTagManager.initialize({ id: "GTM-000000" });
# Attach ecommerce to an event
GTagManager.event("test", {
'currencyCode': 'EUR',
'impressions': [
{
'name': 'Triblend Android T-Shirt',
'id': '12345',
'price': '15.25',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Gray',
'list': 'Search Results',
'position': 1
}]
})
```
### Ecommerce only example:
If you do not want to attach ecommerce obj to event try this:
```js
import GTagManager from 'ecommerce-gtm'
# With default dataLayer
GTagManager.initialize({ id: "GTM-000000" });
# Attach ecommerce to an event
GTagManager.ecommerce({
'currencyCode': 'EUR',
'impressions': [
{
'name': 'Triblend Android T-Shirt',
'id': '12345',
'price': '15.25',
'brand': 'Google',
'category': 'Apparel',
'variant': 'Gray',
'list': 'Search Results',
'position': 1
}]
})
```
### Note:
- Disabling javascript in the browser can prevent the correct operation of this library.