Skip to content

Commit

Permalink
STRATCONN-1287 - Add support for DoubleClick Floodlight config in in …
Browse files Browse the repository at this point in the history
…Google Ads (GTag) (#730)

* Google Ads (GTag): add support for doubleclick floodlight id

* nit: add floodlightAccountId as an option to the initializer

* bump package.json for google ads
  • Loading branch information
rhall-twilio authored Feb 8, 2023
1 parent 2677648 commit dca45f8
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
6 changes: 5 additions & 1 deletion integrations/google-adwords-new/HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
1.3.0 / 2023-02-08
==================
* Introduces a new setting `floodlightAccountId` to enable passing the DoubleClick Floodlight config ID to GTag's `config` to allow better synergy between these two products.

1.2.0 / 2020-02-18
==================

* Introduces a new setting `disableAdPersonalization` to disable collection of remarketing data for users who do not wish to view personalized ads. When this settiing is `true`, Segment will set `allow_ad_personalization_signals` to false.
* Introduces a new setting `disableAdPersonalization` to disable collection of remarketing data for users who do not wish to view personalized ads. When this setting is `true`, Segment will set `allow_ad_personalization_signals` to false.

1.1.1 / 2019-12-09
==================
Expand Down
5 changes: 5 additions & 0 deletions integrations/google-adwords-new/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ var GoogleAdWordsNew = (module.exports = integration('Google AdWords New')
.option('pageLoadConversions', [])
.option('defaultPageConversion', '')
.option('disableAdPersonalization', false)
.option('floodlightAccountId', '')
// The ID in this line (i.e. the gtag.js ID) does not determine which account(s) will receive data from the tag; rather, it is used to uniquely identify your global site tag. Which account(s) receive data from the tag is determined by calling the config command (and by using the send_to parameter on an event). For instance, if you use Google Analytics, you may already have the gtag.js global site tag installed on your site. In that case, the gtag.js ID may be that of the Google Analytics property where you first obtained the snippet.
.tag(
'<script src="https://www.googletagmanager.com/gtag/js?id={{ accountId }}">'
Expand Down Expand Up @@ -55,7 +56,11 @@ GoogleAdWordsNew.prototype.initialize = function() {
if (self.options.disableAdPersonalization)
window.gtag('set', 'allow_ad_personalization_signals', false);

if (self.options.floodlightAccountId) {
window.gtag('config', self.options.floodlightAccountId, config);
}
window.gtag('config', self.options.accountId, config);

self.ready();
});
};
Expand Down
2 changes: 1 addition & 1 deletion integrations/google-adwords-new/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@segment/analytics.js-integration-google-adwords-new",
"description": "The google-adwords-new analytics.js integration.",
"version": "1.2.1",
"version": "1.3.0",
"keywords": [
"analytics.js",
"analytics.js-integration",
Expand Down
12 changes: 12 additions & 0 deletions integrations/google-adwords-new/test/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,18 @@ describe('Google AdWords New', function() {
analytics.initialize();
analytics.spy(window, 'gtag');
});

it('should support Doubleclick Floodlight account if provided', function(done) {
var floodlightAccountId = 'DC-1234567';
googleadwordsnew.options.floodlightAccountId = floodlightAccountId;
analytics.once('ready', function() {
analytics.deepEqual(window.gtag.args[1], ['config', floodlightAccountId, {}]);
analytics.deepEqual(window.gtag.args[2], ['config', options.accountId, {}]);
done();
});
analytics.initialize();
analytics.spy(window, 'gtag');
});
});

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

0 comments on commit dca45f8

Please sign in to comment.