Socket
Socket
Sign inDemoInstall

gampee

Package Overview
Dependencies
0
Maintainers
2
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    gampee

Helps out with Google Analytics Measurement Protocol Enhanced Ecommerce params


Version published
Weekly downloads
356
increased by22.76%
Maintainers
2
Install size
31.3 kB
Created
Weekly downloads
 

Readme

Source

gampee

Build Status

Converts and validates humanly understandable Enhanced E-commerce params into Measurement Protocol. Friends with universal-analytics.

Example

var gampee = require("gampee"),
	ga = require("universal-analytics");

var ecommerceParams = gampee({
	"type": "impression",
	"list": "search",
	"products": [
		{ "id": "shirtM", "name": "Nice T-Shirt (M)", "position": 1 },
		{ "id": "shirtXL", "name": "Nice T-Shirt (XL)", "position": 2 }
	],
	"currency": "EUR"
});

assert.equal(ecommerceParams, {

	"il0nm": "search",

	"il0pi0id": "shirtM",
	"il0pi0nm": "Nice T-Shirt (M)",
	"il0pi0ps": 1,

	"il0pi1id": "shirtXL",
	"il0pi1nm": "Nice T-Shirt (XL)",
	"il0pi1ps": 2,
	
	"cu": "EUR"
	
});

// send together with a pageview
var ua = ga("UA-00000000-0", "5bbb81ff-0757-44e0-8fcb-f263d982b95a", { debug: true });
ua.pageview(_.merge({ dp: "/search?q=some+product", cd20: "one", cm20: "two" }, ecommerceParams));

Unsupported Measurement Protocol options

  • Custom product dimensions/metrics
  • promo and promo_click

Usage

gampee( EcommerceAction action, [function onValidationError] )
gampee( EcommerceAction[] actionList, [function onValidationError] )

EcommerceAction is an object with a required type property. type can be either an impression or one of ecommerce product actions: click, detail, add, remove, purchase, refund, checkout, checkout_option. Each data item should also have a list of Product[] products.

You can send multiple items with impressions (e.g. when there are multiple lists of products on the page), but only one product action with each analytics hit (event, pageview, etc).

If onValidationError is passed in (default: void), it will be called with details of every validation warning, e.g. gampee( myParams, console.warn.bind(console));

See the table below for required/optional/allowed properties of EcommerceAction and Product.

Note that although documentation says all hit types are allowed, the product information will be discarded if sent with transaction hit type (and probably some others). We have only tried testing full information with pageview and event hit types.

Params

This roughly mirrors the ecommerce.js API.

type
impressionclick, detailadd, removepurchase, refundcheckout, checkout_option
currency
Currency Code
optoptoptoptopt
list
Product Action List, Product Impression List Name
optoptopt
id
Transaction ID
req
affiliation
Transaction Affiliation
opt
revenue
Transaction Revenue
opt
tax
Transaction Tax
opt
shipping
Transaction Shipping
opt
coupon
Coupon Code
opt
step
Checkout Step
opt
option
Checkout Step Option
opt
products[]
id
Product SKU
reqreqreqreqreq
name
Product Name
reqreqreqreqreq
brand
Product Brand
optoptoptoptopt
category
Product Category
optoptoptoptopt
variant
Product Variant
optoptoptoptopt
price
Product Price
optoptoptoptopt
position
Product Position
optopt
coupon
Product Coupon Code
optoptoptopt
quantity
Product Quantity
optoptopt

Google's documentation

Keywords

FAQs

Last updated on 26 Oct 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc