Skip to content

Commit

Permalink
feat: add dcfaid support, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
yashasvibajpai committed Mar 10, 2024
1 parent d025039 commit 1961074
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,10 @@ const googleAdsConfigs = [
{ conversionLabel: 'KhF2CKvCs4gYEIXBi58p', name: productAdded },
],
},
{
conversionId: 'conversionId',
dcfaId: 'dcfaId',
},
];

const trackCallPayload = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,12 @@ describe('GoogleAds init tests', () => {
googleAds.init();
expect(typeof window.gtag).toBe('function');
});

test('should call window.gtag with config and dcfaId when dcfaId is truthy', () => {
const googleAds = new GoogleAds(googleAdsConfigs[7], {}, destinationInfo);
googleAds.init();
expect(typeof window.gtag).toBe('function');
});
});

// Old Config Test Cases
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class GoogleAds {
this.dynamicRemarketing = config.dynamicRemarketing;
this.allowEnhancedConversions = config.allowEnhancedConversions || false;
this.v2 = config.v2 || true;
this.dcfaId = config.dcfaId || '';
this.name = NAME;
({
shouldApplyDeviceModeTransformation: this.shouldApplyDeviceModeTransformation,
Expand Down Expand Up @@ -77,6 +78,10 @@ class GoogleAds {
}

window.gtag('config', this.conversionId, config);

if (this.dcfaId) {
window.gtag('config', this.dcfaId);
}
}

isLoaded() {
Expand Down

0 comments on commit 1961074

Please sign in to comment.