Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wlrp__conversion-tracker

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wlrp__conversion-tracker

WLRP Conversion tracking library based on Google Tag Manager

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Conversion Tracking

Initialization

<script src="path/to/conversion.js"></script>
<script>
// Minimal setup
var config = {
		id: 'GTM-123456'
	},
	reporter = new ConversionReporter(config);
</script>

This will inject the GTM script with the ID provided and initialize the Reporter object.

Setting values

// Set manually
reporter.setAmount(10);
reporter.setQuantity(2);

// Or bind to an element that has a `value` property (i.e. input)
reporter.bindAmount(document.getElementById('amountInput'));
reporter.bindQuantity(document.getElementById('quantityInput'));

This will populate the amount and quantity fields of your Reporter object. Reports can now be sent using these values. Add a custom revenue calculator to the config if you want anything more complex.

Sending the conversion

reporter.sendReport();

Custom calculator

To use a custom calculator for your revenue reporting, pass a function to the Reporter object's constructor that does the calculations. The function must have 2 params (quantity and amount), and must return an integer.

function calculateCustom(quantity, amount) {
	// Only 20% commission from partner sales?
	return (quantity*amount)*0.2;
}

var config = {
		id: 'GTM-123456'
		calculator: calculateCustom
	},
	reporter = new ConversionReporter(config);

Default calculator:

function(quantity, amount) {
	return quantity * amount;
}

Keywords

FAQs

Package last updated on 08 Jan 2020

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc