Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions integrations/facebook-pixel/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2.11.0/ 2020-07-16
==================

* Add support for Limited Data Use. See: https://developers.facebook.com/docs/marketing-apis/data-processing-options

2.10.0/ 2019-12-04
==================

Expand Down
4 changes: 4 additions & 0 deletions integrations/facebook-pixel/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var FacebookPixel = (module.exports = integration('Facebook Pixel')
.option('standardEventsCustomProperties', [])
.option('keyForExternalId', '')
.option('userIdAsExternalId', false)
.option('limitedDataUse', true)
.mapping('standardEvents')
.mapping('legacyEvents')
.mapping('contentTypes')
Expand Down Expand Up @@ -102,6 +103,9 @@ FacebookPixel.prototype.initialize = function() {
if (!this.options.automaticConfiguration) {
window.fbq('set', 'autoConfig', false, this.options.pixelId);
}
if (this.options.limitedDataUse) {
window.fbq('dataProcessingOptions', ['LDU'], 0, 0);
}
if (this.options.initWithExistingTraits) {
var traits = this.formatTraits(this.analytics);
window.fbq('init', this.options.pixelId, traits);
Expand Down
2 changes: 1 addition & 1 deletion integrations/facebook-pixel/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@segment/analytics.js-integration-facebook-pixel",
"description": "The Facebook Pixel analytics.js integration.",
"version": "2.10.0",
"version": "2.11.0",
"keywords": [
"analytics.js",
"analytics.js-integration",
Expand Down
29 changes: 29 additions & 0 deletions integrations/facebook-pixel/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ describe('Facebook Pixel', function() {
pixelId: '123123123',
agent: 'test',
initWithExistingTraits: false,
limitedDataUse: true,
whitelistPiiProperties: [],
blacklistPiiProperties: [],
standardEventsCustomProperties: []
Expand Down Expand Up @@ -147,6 +148,12 @@ describe('Facebook Pixel', function() {
);
});

it('should call dataProcessingOptions if limitedDataUse is enabled', function() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe overkill -- but also add test for when it is disabled?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good call. I'll add one!

analytics.stub(window, 'fbq');
analytics.initialize();
analytics.called(window.fbq, 'dataProcessingOptions', ['LDU'], 0, 0);
});

before(function() {
options.initWithExistingTraits = true;
});
Expand All @@ -171,6 +178,28 @@ describe('Facebook Pixel', function() {
analytics.called(window.fbq, 'init', options.pixelId, payload);
});
});

describe('#initialize without LDU', function() {
before(function() {
options.limitedDataUse = false;
});

after(function() {
options.limitedDataUse = true;
});

it('should not call dataProcessingOptions if limitedDataUse is false', function() {
analytics.stub(window, 'fbq');
analytics.initialize();
analytics.didNotCall(
window.fbq,
'dataProcessingOptions',
['LDU'],
0,
0
);
});
});
});

describe('loading', function() {
Expand Down