Skip to content

Commit 50d2834

Browse files
Add integration wigzo This commit copies the content of the integration repo into the "integrations" folder. Original repo: https://github.com/segment-integrations/analytics.js-integration-wigzo Readme: https://github.com/segment-integrations/analytics.js-integration-wigzo/blob/master/README.md
1 parent 0060537 commit 50d2834

File tree

6 files changed

+704
-0
lines changed

6 files changed

+704
-0
lines changed

integrations/wigzo/HISTORY.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
1.3.0 / 2017-10-13
2+
==================
3+
4+
* Updated with new js integration code
5+
6+
1.2.0 / 2017-05-28
7+
==================
8+
9+
* Bugs Fixed, pageUrl treated as canonicalUrl
10+
11+
1.1.0 / 2017-05-28
12+
==================
13+
14+
* Add ecommerce events, update `.identify()` and `.page()`
15+
16+
1.0.0 / 2017-05-18
17+
==================
18+
19+
* Initial release :sparkles:
20+
21+
0.0.1 / 2017-05-18
22+
==================
23+
24+
* Initial scaffold :sparkles:

integrations/wigzo/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# analytics.js-integration-wigzo
2+
[![CircleCI](https://circleci.com/gh/segment-integrations/analytics.js-integration-wigzo.svg?style=svg)](https://circleci.com/gh/segment-integrations/analytics.js-integration-wigzo)
3+
4+
The analytics.js integration for Wigzo

integrations/wigzo/lib/index.js

Lines changed: 240 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,240 @@
1+
'use strict';
2+
3+
var integration = require('@segment/analytics.js-integration');
4+
var reject = require('reject');
5+
var when = require('do-when');
6+
7+
/**
8+
* Expose `Wigzo` integration
9+
*/
10+
11+
var Wigzo = module.exports = integration('Wigzo')
12+
.global('wigzo')
13+
.option('orgToken', '')
14+
.tag('tracker', '<script src="https://app.wigzo.com/wigzo.compressed.js">');
15+
16+
/**
17+
* Initialize Wigzo
18+
*/
19+
20+
Wigzo.prototype.initialize = function() {
21+
var orgToken = this.options.orgToken;
22+
var self = this;
23+
24+
/* eslint-disable */
25+
// setup the tracker globals
26+
window.WigzoObject = 'wigzo';
27+
window.wigzo = window.wigzo || function() {
28+
window.wigzo.q = window.wigzo.q || [];
29+
window.wigzo.q.push(arguments);
30+
};
31+
window.wigzo.l = new Date().getTime();
32+
/* eslint-enable */
33+
34+
window.wigzo.integrationSource = 'Segment';
35+
window.wigzo('configure', orgToken);
36+
37+
this.load('tracker', function() {
38+
// make sure necessary functions and objects exist
39+
when(self.loaded, self.ready);
40+
});
41+
};
42+
43+
/**
44+
* Loaded?
45+
*
46+
* @api private
47+
* @return {boolean}
48+
*/
49+
50+
Wigzo.prototype.loaded = function() {
51+
return !!window.wigzo;
52+
};
53+
54+
/**
55+
* Product Added
56+
*
57+
* @param {Track} track
58+
*/
59+
60+
Wigzo.prototype.productAdded = function(track) {
61+
var productId = track.productId();
62+
if (productId) window.wigzo.track('addtocart', productId);
63+
};
64+
65+
66+
/**
67+
* Wishlist Product Added to Cart
68+
*
69+
* @param {Track} track
70+
*/
71+
72+
Wigzo.prototype.productAddedFromWishlistToCart = function(track) {
73+
var productId = track.productId();
74+
if (productId) window.wigzo.track('addtocart', productId);
75+
};
76+
77+
/**
78+
* Product Removed
79+
*
80+
* @param {Track} track
81+
*/
82+
83+
Wigzo.prototype.productRemoved = function(track) {
84+
var productId = track.productId();
85+
if (productId) window.wigzo.track('removedfromcart', productId);
86+
};
87+
88+
/**
89+
* Products Searched
90+
*
91+
* @param {Track} track
92+
*/
93+
94+
Wigzo.prototype.productsSearched = function(track) {
95+
var props = track.properties();
96+
if (props.query) {
97+
window.wigzo.track('search', props.query);
98+
}
99+
};
100+
101+
/**
102+
* Product Added to Wishlist
103+
*
104+
* @param {Track} track
105+
*/
106+
107+
Wigzo.prototype.productAddedToWishlist = function(track) {
108+
var productId = track.productId();
109+
if (productId) window.wigzo.track('wishlist', productId);
110+
};
111+
112+
113+
/**
114+
* Checkout Started
115+
*
116+
* @param {Track} track
117+
*/
118+
119+
Wigzo.prototype.checkoutStarted = function(track) {
120+
var productList = track.products();
121+
var addedProductIds = [];
122+
for (var i = 0; i < productList.length; i++) {
123+
var item = productList[i];
124+
addedProductIds.push(item.product_id || item.productId);
125+
}
126+
127+
if (addedProductIds.length) window.wigzo.track('checkoutstarted', addedProductIds);
128+
};
129+
130+
/**
131+
* Completed Order
132+
*
133+
* @param {Track} track
134+
*/
135+
136+
Wigzo.prototype.orderCompleted = function(track) {
137+
var productList = track.products();
138+
var addedProductIds = [];
139+
for (var i = 0; i < productList.length; i++) {
140+
var item = productList[i];
141+
addedProductIds.push(item.product_id || item.productId);
142+
}
143+
144+
if (addedProductIds.length) window.wigzo.track('buy', addedProductIds);
145+
};
146+
147+
/**
148+
* Product Review
149+
*
150+
* @param {Track} track
151+
*/
152+
Wigzo.prototype.productReviewed = function(track) {
153+
window.wigzo.track('review', track.properties());
154+
};
155+
156+
/**
157+
* Product Clicked
158+
*
159+
* @param {Track} track
160+
*/
161+
Wigzo.prototype.productClicked = function(track) {
162+
var options = track.options(this.name);
163+
var traits = reject({
164+
productId : track.productId(),
165+
title: track.name(),
166+
price: track.currency() + ' ' + track.price(),
167+
category: track.category(),
168+
canonicalUrl: track.proxy('context.page.url'),
169+
/* custom props */
170+
image: options.imageUrl,
171+
description: options.description,
172+
language:options.language
173+
});
174+
window.wigzo.index(traits);
175+
};
176+
177+
/**
178+
* Product Viewed
179+
*
180+
* @param {Track} track
181+
*/
182+
Wigzo.prototype.productViewed = function(track) {
183+
var options = track.options(this.name);
184+
var traits = reject({
185+
productId : track.productId(),
186+
title: track.name(),
187+
price: track.currency() + ' ' + track.price(),
188+
category: track.category(),
189+
canonicalUrl: track.proxy('context.page.url'),
190+
/* custom props */
191+
image: options.imageUrl,
192+
description: options.description,
193+
language:options.language
194+
});
195+
window.wigzo.index(traits);
196+
};
197+
198+
/**
199+
* Identify.
200+
*
201+
* @api public
202+
* @param {Identify} identify
203+
*/
204+
205+
Wigzo.prototype.identify = function(identify) {
206+
var id = identify.userId();
207+
if (id) window.wigzo.USER_IDENTIFIER = id;
208+
209+
var traits = reject({
210+
email: identify.email(),
211+
phone: identify.phone(),
212+
fullName: identify.name()
213+
});
214+
window.wigzo.identify(traits);
215+
};
216+
217+
/**
218+
* Track.
219+
*
220+
* @api public
221+
* @param {Track} track
222+
*/
223+
224+
Wigzo.prototype.track = function(track) {
225+
window.wigzo.track(track.event(), track.properties());
226+
};
227+
228+
/**
229+
* Page.
230+
*
231+
* @param {Page} page
232+
*/
233+
234+
Wigzo.prototype.page = function(page) {
235+
var pageData = reject({
236+
canonicalUrl: page.url(),
237+
title: page.name()
238+
});
239+
window.wigzo.track('view',pageData);
240+
};

integrations/wigzo/package.json

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
{
2+
"name": "@segment/analytics.js-integration-wigzo",
3+
"description": "The wigzo analytics.js integration.",
4+
"version": "1.3.0",
5+
"keywords": null,
6+
"main": "lib/index.js",
7+
"scripts": {
8+
"test": "make test"
9+
},
10+
"author": "Segment",
11+
"license": "SEE LICENSE IN LICENSE",
12+
"homepage": "https://github.com/segmentio/analytics.js-integrations/blob/master/integrations/wigzo#readme",
13+
"bugs": {
14+
"url": "https://github.com/segmentio/analytics.js-integrations/issues"
15+
},
16+
"repository": {
17+
"type": "git",
18+
"url": "git+https://github.com/segmentio/analytics.js-integrations.git"
19+
},
20+
"dependencies": {
21+
"@segment/analytics.js-integration": "^3.2.0",
22+
"do-when": "^1.0.0",
23+
"reject": "0.0.1",
24+
"use-https": "^0.1.1"
25+
},
26+
"devDependencies": {
27+
"@segment/analytics.js-core": "^3.0.0",
28+
"@segment/analytics.js-integration-tester": "^3.1.1",
29+
"@segment/clear-env": "^2.1.0",
30+
"@segment/eslint-config": "^3.1.1",
31+
"browserify": "^13.0.0",
32+
"browserify-istanbul": "^2.0.0",
33+
"eslint": "^2.9.0",
34+
"eslint-plugin-mocha": "^2.2.0",
35+
"eslint-plugin-require-path-exists": "^1.1.5",
36+
"istanbul": "^0.4.5",
37+
"karma": "1.3.0",
38+
"karma-browserify": "^5.1.1",
39+
"karma-chrome-launcher": "^2.0.0",
40+
"karma-coverage": "^1.1.1",
41+
"karma-junit-reporter": "^1.2.0",
42+
"karma-mocha": "1.0.1",
43+
"karma-phantomjs-launcher": "^1.0.4",
44+
"karma-sauce-launcher": "^1.1.0",
45+
"karma-spec-reporter": "0.0.26",
46+
"mocha": "^3.3.0",
47+
"npm-check": "^5.4.0",
48+
"phantomjs-prebuilt": "^2.1.14",
49+
"watchify": "^3.9.0"
50+
}
51+
}

integrations/wigzo/test/.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "@segment/eslint-config/mocha"
3+
}

0 commit comments

Comments
 (0)