-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This commit copies the content of the integration repo into the "integrations" folder. Original repo: https://github.com/segment-integrations/analytics.js-integration-adwords Readme: https://github.com/segment-integrations/analytics.js-integration-adwords/blob/master/README.md
- Loading branch information
1 parent
7226576
commit 81846a3
Showing
6 changed files
with
585 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
|
||
2.5.2 / 2018-02-23 | ||
================== | ||
|
||
* prep for mixed component migration | ||
|
||
2.5.1 / 2017-10-30 | ||
================== | ||
|
||
* tag bump | ||
* Merge pull request #16 from segment-integrations/adwords-multiple-ids | ||
|
||
2.5.0 / 2017-10-30 | ||
================== | ||
|
||
* Merge pull request #16 from segment-integrations/adwords-multiple-ids | ||
|
||
2.4.0 / 2017-01-05 | ||
================== | ||
|
||
* Support sending standalone Remarketing Tags | ||
|
||
|
||
2.3.0 / 2016-11-16 | ||
================== | ||
|
||
* Support Dynamic Remarketing Tags | ||
|
||
2.2.0 / 2016-11-15 | ||
================== | ||
|
||
* Prevent Adwords from crashing due to adblockers | ||
|
||
2.1.1 / 2016-09-22 | ||
================== | ||
|
||
* Revert "Dynamic remarketing" | ||
|
||
2.1.0 / 2016-09-15 | ||
================== | ||
|
||
* support dynamic remarketing | ||
|
||
2.0.0 / 2016-06-21 | ||
================== | ||
|
||
* Remove Duo compatibility | ||
* Add CI setup (coverage, linting, cross-browser compatibility, etc.) | ||
* Update eslint configuration | ||
|
||
1.0.6 / 2016-05-07 | ||
================== | ||
|
||
* Bump Analytics.js core, tester, integration to use Facade 2.x | ||
|
||
1.0.5 / 2015-08-27 | ||
================== | ||
|
||
* add check for google_trackConversion in loaded function. | ||
|
||
1.0.4 / 2015-06-30 | ||
================== | ||
|
||
* Replace analytics.js dependency with analytics.js-core | ||
|
||
1.0.3 / 2015-06-30 | ||
================== | ||
|
||
* Replace analytics.js dependency with analytics.js-core | ||
|
||
1.0.2 / 2015-06-24 | ||
================== | ||
|
||
* Bump analytics.js-integration version | ||
|
||
1.0.1 / 2015-06-24 | ||
================== | ||
|
||
* Bump analytics.js-integration version | ||
|
||
1.0.0 / 2015-06-09 | ||
================== | ||
|
||
* Initial commit :sparkles: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# analytics.js-integration-adwords [![Build Status][ci-badge]][ci-link] | ||
|
||
Adwords integration for [Analytics.js][]. | ||
|
||
## License | ||
|
||
Released under the [MIT license](LICENSE). | ||
|
||
|
||
[Analytics.js]: https://segment.com/docs/libraries/analytics.js/ | ||
[ci-link]: https://circleci.com/gh/segment-integrations/analytics.js-integration-adwords | ||
[ci-badge]: https://circleci.com/gh/segment-integrations/analytics.js-integration-adwords.svg?style=svg |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var integration = require('@segment/analytics.js-integration'); | ||
var when = require('do-when'); | ||
|
||
/** | ||
* Expose `AdWords`. | ||
*/ | ||
|
||
var AdWords = module.exports = integration('AdWords') | ||
.option('conversionId', '') | ||
.option('pageRemarketing', false) | ||
.option('eventMappings', []) | ||
.tag('<script src="//www.googleadservices.com/pagead/conversion_async.js">'); | ||
|
||
/** | ||
* Initialize. | ||
* | ||
* @api public | ||
*/ | ||
|
||
AdWords.prototype.initialize = function() { | ||
var loaded = this.loaded; | ||
var ready = this.ready; | ||
this.load(function() { | ||
when(loaded, ready); | ||
}); | ||
}; | ||
|
||
/** | ||
* Loaded. | ||
* | ||
* @api private | ||
* @return {boolean} | ||
*/ | ||
|
||
AdWords.prototype.loaded = function() { | ||
return !!(document.body && window.google_trackConversion); | ||
}; | ||
|
||
/** | ||
* Page. | ||
* | ||
* https://support.google.com/adwords/answer/3111920#standard_parameters | ||
* https://support.google.com/adwords/answer/3103357 | ||
* https://developers.google.com/adwords-remarketing-tag/asynchronous/ | ||
* https://developers.google.com/adwords-remarketing-tag/parameters | ||
* | ||
* @api public | ||
* @param {Page} page | ||
*/ | ||
|
||
AdWords.prototype.page = function(page) { | ||
// Remarketing option can support both Adwords' "static" or "dynamic" remarketing tags | ||
// Difference is static you don't need to send props under `google_custom_params` | ||
var remarketing = this.options.pageRemarketing; | ||
var id = this.options.conversionId; | ||
var props = page.properties(); | ||
|
||
// Conversion tag | ||
window.google_trackConversion({ | ||
google_conversion_id: id, | ||
google_custom_params: {}, | ||
google_remarketing_only: false // this ensures that this is a conversion tag | ||
}); | ||
|
||
// Remarketing tag (must be sent in _addition_ to any conversion tags) | ||
// https://developers.google.com/adwords-remarketing-tag/ | ||
if (remarketing) { | ||
window.google_trackConversion({ | ||
google_conversion_id: id, | ||
google_custom_params: props, | ||
google_remarketing_only: true // this ensures that this is a remarketing tag | ||
}); | ||
} | ||
}; | ||
|
||
/** | ||
* Track. | ||
* | ||
* @api public | ||
* @param {Track} | ||
*/ | ||
|
||
AdWords.prototype.track = function(track) { | ||
var self = this; | ||
var props = track.properties(); | ||
var eventMappings = this.options.eventMappings; | ||
var revenue = track.revenue() || 0; | ||
|
||
eventMappings.forEach(function(mapping) { | ||
if (mapping.value) { | ||
if (mapping.value.eventName.toLowerCase() !== track.event().toLowerCase()) return; | ||
var id = mapping.value.conversionId || self.options.conversionId; // customer can either specify one global conversion id or one per mapping | ||
|
||
// Fire conversion tag | ||
if (mapping.value.label !== '') { | ||
delete props.revenue; | ||
|
||
window.google_trackConversion({ | ||
google_conversion_id: id, | ||
google_custom_params: props, | ||
google_conversion_language: 'en', | ||
google_conversion_format: '3', | ||
google_conversion_color: 'ffffff', | ||
google_conversion_label: mapping.value.label, | ||
google_conversion_value: revenue, | ||
google_remarketing_only: false // ensure this is a conversion tag | ||
}); | ||
} | ||
|
||
// Fire remarketing tag | ||
if (mapping.value.remarketing) { | ||
window.google_trackConversion({ | ||
google_conversion_id: id, | ||
google_custom_params: props, // do not send PII here! | ||
google_remarketing_only: true // ensure this is a remarketing tag | ||
}); | ||
} | ||
} else { | ||
if (mapping.eventName.toLowerCase() !== track.event().toLowerCase()) return; | ||
id = mapping.conversionId || self.options.conversionId; // customer can either specify one global conversion id or one per mapping | ||
|
||
// Fire conversion tag | ||
if (mapping.label !== '') { | ||
delete props.revenue; | ||
|
||
window.google_trackConversion({ | ||
google_conversion_id: id, | ||
google_custom_params: props, | ||
google_conversion_language: 'en', | ||
google_conversion_format: '3', | ||
google_conversion_color: 'ffffff', | ||
google_conversion_label: mapping.label, | ||
google_conversion_value: revenue, | ||
google_remarketing_only: false // ensure this is a conversion tag | ||
}); | ||
} | ||
|
||
// Fire remarketing tag | ||
if (mapping.remarketing) { | ||
window.google_trackConversion({ | ||
google_conversion_id: id, | ||
google_custom_params: props, // do not send PII here! | ||
google_remarketing_only: true // ensure this is a remarketing tag | ||
}); | ||
} | ||
} | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
{ | ||
"name": "@segment/analytics.js-integration-adwords", | ||
"description": "The Adwords analytics.js integration.", | ||
"version": "2.5.2", | ||
"keywords": [ | ||
"analytics.js", | ||
"analytics.js-integration", | ||
"segment", | ||
"adwords" | ||
], | ||
"main": "lib/index.js", | ||
"scripts": { | ||
"test": "make test" | ||
}, | ||
"author": "Segment \u003c[email protected]\u003e", | ||
"license": "SEE LICENSE IN LICENSE", | ||
"homepage": "https://github.com/segmentio/analytics.js-integrations/blob/master/integrations/adwords#readme", | ||
"bugs": { | ||
"url": "https://github.com/segmentio/analytics.js-integrations/issues" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/segmentio/analytics.js-integrations.git" | ||
}, | ||
"dependencies": { | ||
"@ndhoule/each": "^2.0.1", | ||
"@segment/analytics.js-integration": "^2.1.0", | ||
"do-when": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"@segment/analytics.js-core": "^3.0.0", | ||
"@segment/analytics.js-integration-tester": "^3.1.0", | ||
"@segment/clear-env": "^2.0.0", | ||
"@segment/eslint-config": "^3.1.1", | ||
"browserify": "^13.0.0", | ||
"browserify-istanbul": "^2.0.0", | ||
"eslint": "^2.9.0", | ||
"eslint-plugin-mocha": "^2.2.0", | ||
"eslint-plugin-require-path-exists": "^1.1.5", | ||
"istanbul": "^0.4.3", | ||
"karma": "1.3.0", | ||
"karma-browserify": "^5.0.4", | ||
"karma-chrome-launcher": "^1.0.1", | ||
"karma-coverage": "^1.0.0", | ||
"karma-junit-reporter": "^1.0.0", | ||
"karma-mocha": "1.0.1", | ||
"karma-phantomjs-launcher": "^1.0.0", | ||
"karma-sauce-launcher": "^1.0.0", | ||
"karma-spec-reporter": "0.0.26", | ||
"mocha": "^2.2.5", | ||
"npm-check": "^5.2.1", | ||
"phantomjs-prebuilt": "^2.1.7", | ||
"watchify": "^3.7.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"extends": "@segment/eslint-config/mocha" | ||
} |
Oops, something went wrong.