Skip to content

Commit

Permalink
1.0.5, add tz timezone
Browse files Browse the repository at this point in the history
also switches to implicit return arrow functions
  • Loading branch information
stuyam committed Mar 20, 2019
1 parent 70da9c1 commit 659285a
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 32 deletions.
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,13 @@ There are 2 automatic events, the `pageload` event which is sent as the main eve
Openpixel is flexible with events though, you can make calls to any events with any data you want to be sent with the beacon. Whenever an event is called, it sends a beacon just like the other beacons that have a timestamp and everything else. Here is an example of a custom event being called. Note: In this case we are using the `opix` function name but this will be custom based on your build of openpixel.

```
opix("event","reservation requested")
opix('event', 'reservation_requested')
```
You can also pass a string or json as the third parameter to send other data with the event.

```
opix("event","reservation requested", {someData: 1, otherData: "cool"})
opix('event', 'reservation_requested', {someData: 1, otherData: 'cool'})
opix('event', 'reservation_requested', {someData: 1, otherData: 'cool'})
```

## Setup and Customize
Expand Down Expand Up @@ -85,6 +86,7 @@ https://tracker.example.com/pixel.gif?id=R29X8&uid=1-ovbam3yz-iolwx617&ev=pagelo
| bn | Chrome 50 | browser name |
| md | false | mobile device |
| ua | _full user agent_ | user agent |
| tz | 240 | timezone offset (minutes away from utc) |
| utm_source | | Campaign Source |
| utm_medium | | Campaign Medium |
| utm_term | | Campaign Term |
Expand Down
6 changes: 5 additions & 1 deletion dist/openpixel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Open Pixel v1.0.2 | Published By Dockwa | Created By Stuart Yamartino | MIT License
// Open Pixel v1.0.5 | Published By Dockwa | Created By Stuart Yamartino | MIT License
;(function(window, document, pixelFunc, pixelFuncName, pixelEndpoint, versionNumber) {
"use strict";

Expand Down Expand Up @@ -262,6 +262,10 @@ function () {
return Browser.userAgent();
},
// user agent
tz: function tz() {
return new Date().getTimezoneOffset();
},
// timezone
utm_source: function utm_source(key) {
return Cookie.getUtm(key);
},
Expand Down
4 changes: 2 additions & 2 deletions dist/openpixel.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// ---------- Configurations for your custom build of open pixel ---------- //

// This is the header comment that will be included at the top of the "dist/openpixel.js" file
var HEADER_COMMENT = process.env.OPIX_HEADER_COMMENT || '// Open Pixel v1.0.2 | Published By Dockwa | Created By Stuart Yamartino | MIT License\n';
var HEADER_COMMENT = process.env.OPIX_HEADER_COMMENT || '// Open Pixel v1.0.5 | Published By Dockwa | Created By Stuart Yamartino | MIT License\n';

// This is where the compiled snippet and openpixel.js files will be dropped
var DESTINATION_FOLDER = process.env.OPIX_DESTINATION_FOLDER || './dist';
Expand Down
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "openpixel",
"version": "1.0.4",
"version": "1.0.5",
"description": "Open Pixel is a JavaScript library for creating embeddable and intelligent tracking pixels",
"main": "openpixel.min.js",
"dependencies": {
Expand Down
44 changes: 22 additions & 22 deletions src/pixel.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,28 +19,28 @@ class Pixel {

getAttribute() {
return {
id: ()=>{return Config.id}, // website Id
uid: ()=>{return Cookie.get('uid')}, // user Id
ev: ()=>{return this.event}, // event being triggered
ed: ()=>{return this.optinal}, // any event data to pass along
v: ()=>{return Config.version}, // openpixel.js version
dl: ()=>{return window.location.href}, // document location
rl: ()=>{return document.referrer}, // referrer location
ts: ()=>{return this.timestamp}, // timestamp when event was triggered
de: ()=>{return document.characterSet}, // document encoding
sr: ()=>{return window.screen.width + 'x' + window.screen.height}, // screen resolution
vp: ()=>{return window.innerWidth + 'x' + window.innerHeight}, // viewport size
cd: ()=>{return window.screen.colorDepth}, // color depth
dt: ()=>{return document.title}, // document title
bn: ()=>{return Browser.nameAndVersion()}, // browser name and version number
md: ()=>{return Browser.isMobile()}, // is a mobile device?
ua: ()=>{return Browser.userAgent()}, // user agent
tz: ()=>{return (new Date()).getTimezoneOffset()}, // timezone
utm_source: (key)=>{return Cookie.getUtm(key)}, // get the utm source
utm_medium: (key)=>{return Cookie.getUtm(key)}, // get the utm medium
utm_term: (key)=>{return Cookie.getUtm(key)}, // get the utm term
utm_content: (key)=>{return Cookie.getUtm(key)}, // get the utm concent
utm_campaign: (key)=>{return Cookie.getUtm(key)}, // get the utm campaign
id: () => Config.id, // website Id
uid: () => Cookie.get('uid'), // user Id
ev: () => this.event, // event being triggered
ed: () => this.optinal, // any event data to pass along
v: () => Config.version, // openpixel.js version
dl: () => window.location.href, // document location
rl: () => document.referrer, // referrer location
ts: () => this.timestamp, // timestamp when event was triggered
de: () => document.characterSet, // document encoding
sr: () => window.screen.width + 'x' + window.screen.height, // screen resolution
vp: () => window.innerWidth + 'x' + window.innerHeight, // viewport size
cd: () => window.screen.colorDepth, // color depth
dt: () => document.title, // document title
bn: () => Browser.nameAndVersion(), // browser name and version number
md: () => Browser.isMobile(), // is a mobile device?
ua: () => Browser.userAgent(), // user agent
tz: () => (new Date()).getTimezoneOffset(), // timezone
utm_source: key => Cookie.getUtm(key), // get the utm source
utm_medium: key => Cookie.getUtm(key), // get the utm medium
utm_term: key => Cookie.getUtm(key), // get the utm term
utm_content: key => Cookie.getUtm(key), // get the utm concent
utm_campaign: key => Cookie.getUtm(key), // get the utm campaign
}
}

Expand Down

0 comments on commit 659285a

Please sign in to comment.