Skip to content

Commit bafc009

Browse files
Rename marketing to analytics for consistency
1 parent 18ac793 commit bafc009

5 files changed

Lines changed: 207 additions & 207 deletions

File tree

media/js/base/consent/utils.es6.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,12 +54,12 @@ function setGtagAnalyticsConsentMode(hasConsent, type = 'update') {
5454
window.gtag('consent', type, {
5555
analytics_storage: 'granted'
5656
});
57-
DownloadAttribution.initMarketing(true);
57+
DownloadAttribution.initAnalytics(true);
5858
} else {
5959
window.gtag('consent', type, {
6060
analytics_storage: 'denied'
6161
});
62-
DownloadAttribution.initMarketing(false);
62+
DownloadAttribution.initAnalytics(false);
6363
}
6464
return true;
6565
}

media/js/base/download-attribution/download-attribution.es6.js

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,12 @@ window.dataLayer = window.dataLayer || [];
2020
* this name: https://github.com/mozilla-services/stubattribution.
2121
* Refactor task: https://mozilla-hub.atlassian.net/browse/WT-964
2222
*
23-
* Essential and marketing attribution are driven by independent triggers and know
23+
* Essential and analytics attribution are driven by independent triggers and know
2424
* nothing about each other:
2525
* - Essential (rtamo, download_as_default, smart_window) is required for functional
2626
* post-download behavior. It runs without consent gating or sample-rate limiting,
2727
* triggered by a `data-stub-attribution-campaign-force` attribute on the current page.
28-
* - Marketing is consent-gated and sample-rated, triggered by a `gtm-marketing-consent`
28+
* - Analytics is consent-gated and sample-rated, triggered by a `gtm-analytics-consent`
2929
* event dispatched from GTM.
3030
* Each trigger reads the other's last-captured raw data from a side cookie so it can
3131
* re-sign the combined payload without the other trigger having fired on this page.
@@ -34,13 +34,13 @@ const DownloadAttribution = {
3434
COOKIE_CODE_ID: 'moz-download-attribution-code',
3535
COOKIE_SIGNATURE_ID: 'moz-download-attribution-sig',
3636
COOKIE_ESSENTIAL_RAW_ID: 'moz-download-attribution-essential-raw',
37-
COOKIE_MARKETING_RAW_ID: 'moz-download-attribution-marketing-raw',
37+
COOKIE_ANALYTICS_RAW_ID: 'moz-download-attribution-analytics-raw',
3838
DLSOURCE: 'fxdotcom',
3939
ESSENTIAL_CAMPAIGNS: ['rtamo', 'SET_AS_DEFAULT', 'smart_window'],
4040

4141
/**
4242
* Custom event handler callback globals. These can be defined as functions when
43-
* calling DownloadAttribution.initEssential() or .initMarketing().
43+
* calling DownloadAttribution.initEssential() or .initAnalytics().
4444
*/
4545
successCallback: undefined,
4646
timeoutCallback: undefined,
@@ -151,9 +151,9 @@ const DownloadAttribution = {
151151
/**
152152
* Stores a raw attribution data object as a JSON-encoded cookie.
153153
* Raw cookies preserve the inputs used to build the signed payload so
154-
* either trigger (essential or marketing) can re-sign the combined
154+
* either trigger (essential or analytics) can re-sign the combined
155155
* payload without the other having fired on the current page.
156-
* @param {String} id - COOKIE_ESSENTIAL_RAW_ID or COOKIE_MARKETING_RAW_ID.
156+
* @param {String} id - COOKIE_ESSENTIAL_RAW_ID or COOKIE_ANALYTICS_RAW_ID.
157157
* @param {Object} data - Raw attribution data to preserve.
158158
*/
159159
setRawCookie: (id, data) => {
@@ -316,7 +316,7 @@ const DownloadAttribution = {
316316
DownloadAttribution.COOKIE_ESSENTIAL_RAW_ID
317317
);
318318
DownloadAttribution.removeRawCookie(
319-
DownloadAttribution.COOKIE_MARKETING_RAW_ID
319+
DownloadAttribution.COOKIE_ANALYTICS_RAW_ID
320320
);
321321
DownloadAttribution.cleanBouncerLinks();
322322
DownloadAttribution.requestComplete = false;
@@ -547,12 +547,12 @@ const DownloadAttribution = {
547547
},
548548

549549
/**
550-
* Gets the marketing campaign value: utm_campaign from the URL, falling
550+
* Gets the analytics campaign value: utm_campaign from the URL, falling
551551
* back to the page-level default campaign attribute.
552552
* @param {Object} params - URL params.
553553
* @return {String | null} - Campaign value, or null.
554554
*/
555-
getMarketingCampaign: (params) => {
555+
getAnalyticsCampaign: (params) => {
556556
const utms = params.utmParams();
557557
if (utms.utm_campaign !== undefined) {
558558
return utms.utm_campaign;
@@ -566,7 +566,7 @@ const DownloadAttribution = {
566566
* Gets essential data for download.
567567
* Until the stub attribution service is updated to accept dedicated
568568
* essential fields, essential data carries its campaign in utm_campaign;
569-
* essential wins on key collisions with marketing when merged.
569+
* essential wins on key collisions with analytics when merged.
570570
* @return {Object} - Essential data object, or {} if the current page
571571
* does not carry a recognized essential campaign.
572572
*/
@@ -599,17 +599,17 @@ const DownloadAttribution = {
599599
},
600600

601601
/**
602-
* Gets marketing data for download. Requires GA4 wait.
602+
* Gets analytics data for download. Requires GA4 wait.
603603
* @param {String} ref - Optional referrer to facilitate testing.
604604
* @param {Object} params - URL params.
605-
* @return {Object} - Marketing download attribution data object.
605+
* @return {Object} - Analytics download attribution data object.
606606
*/
607-
getMarketingData: (ref, params) => {
607+
getAnalyticsData: (ref, params) => {
608608
const utms = params.utmParams();
609609
return {
610610
utm_source: utms.utm_source,
611611
utm_medium: utms.utm_medium,
612-
utm_campaign: DownloadAttribution.getMarketingCampaign(params),
612+
utm_campaign: DownloadAttribution.getAnalyticsCampaign(params),
613613
utm_content: utms.utm_content,
614614
referrer: typeof ref === 'string' ? ref : document.referrer,
615615
ua: DownloadAttribution.getUserAgent(),
@@ -659,15 +659,15 @@ const DownloadAttribution = {
659659
},
660660

661661
/**
662-
* Merges essential and marketing data and requests an updated signed
662+
* Merges essential and analytics data and requests an updated signed
663663
* payload from the stub attribution service. Essential keys override
664-
* marketing on collision (today only utm_campaign collides; a pending
664+
* analytics on collision (today only utm_campaign collides; a pending
665665
* service update will give essential dedicated fields).
666666
* @param {Object | null} essential - Essential data, or null.
667-
* @param {Object | null} marketing - Marketing data, or null.
667+
* @param {Object | null} analytics - Analytics data, or null.
668668
*/
669-
requestCombinedAuth: (essential, marketing) => {
670-
const combined = Object.assign({}, marketing || {}, essential || {});
669+
requestCombinedAuth: (essential, analytics) => {
670+
const combined = Object.assign({}, analytics || {}, essential || {});
671671

672672
// Remove undefined / null values.
673673
for (const key of Object.keys(combined)) {
@@ -735,7 +735,7 @@ const DownloadAttribution = {
735735
/**
736736
* Essential trigger entry point. Runs on pages that carry essential
737737
* download data (functional post-download behavior such as rtamo).
738-
* Does not gate on marketing consent or sample rate: essential data
738+
* Does not gate on analytics consent or sample rate: essential data
739739
* must always be carried so the installer can deliver its promised
740740
* functionality after download.
741741
* @param {string} campaign - Optional.
@@ -757,19 +757,19 @@ const DownloadAttribution = {
757757

758758
const essential = DownloadAttribution.getEssentialData(campaign);
759759

760-
const marketing = DownloadAttribution.getRawCookie(
761-
DownloadAttribution.COOKIE_MARKETING_RAW_ID
760+
const analytics = DownloadAttribution.getRawCookie(
761+
DownloadAttribution.COOKIE_ANALYTICS_RAW_ID
762762
);
763763

764764
// We have last touch essential attribution to avoid a stale download experience
765765
// REMOVE essential data if it is no longer applicable
766766
if (Object.keys(essential).length === 0) {
767-
if (marketing) {
767+
if (analytics) {
768768
// remove essential only
769769
DownloadAttribution.removeRawCookie(
770770
DownloadAttribution.COOKIE_ESSENTIAL_RAW_ID
771771
);
772-
DownloadAttribution.requestCombinedAuth(null, marketing);
772+
DownloadAttribution.requestCombinedAuth(null, analytics);
773773
} else {
774774
DownloadAttribution.removeAttributionData();
775775
// we didn't make a stub attribution call, but we've completed clean-up
@@ -783,20 +783,20 @@ const DownloadAttribution = {
783783
essential
784784
);
785785

786-
DownloadAttribution.requestCombinedAuth(essential, marketing);
786+
DownloadAttribution.requestCombinedAuth(essential, analytics);
787787
}
788788
},
789789

790790
/**
791-
* Marketing trigger entry point. On 'granted', captures marketing data
791+
* Analytics trigger entry point. On 'granted', captures analytics data
792792
* from the current URL and re-signs the combined payload. On 'denied',
793-
* clears marketing data; if essential data is also absent, the full
793+
* clears analytics data; if essential data is also absent, the full
794794
* attribution state is removed.
795795
* @param {Boolean} isConsentGranted - Based on GTM Consent Analytics Storage.
796796
* @param {Function} successCallback - Optional.
797797
* @param {Function} timeoutCallback - Optional.
798798
*/
799-
initMarketing: (isConsentGranted, successCallback, timeoutCallback) => {
799+
initAnalytics: (isConsentGranted, successCallback, timeoutCallback) => {
800800
if (!DownloadAttribution.meetsFunctionalRequirements()) {
801801
return;
802802
}
@@ -810,11 +810,11 @@ const DownloadAttribution = {
810810
}
811811

812812
if (isConsentGranted) {
813-
// We have first touch marketing attribution
814-
// DO NOT UPDATE if we have existing marketing data
813+
// We have first touch analytics attribution
814+
// DO NOT UPDATE if we have existing analytics data
815815
if (
816816
DownloadAttribution.getRawCookie(
817-
DownloadAttribution.COOKIE_MARKETING_RAW_ID
817+
DownloadAttribution.COOKIE_ANALYTICS_RAW_ID
818818
)
819819
) {
820820
return;
@@ -826,26 +826,26 @@ const DownloadAttribution = {
826826

827827
DownloadAttribution.waitForGoogleAnalyticsThen(() => {
828828
const params = new window._SearchParams();
829-
const marketing = DownloadAttribution.getMarketingData(
829+
const analytics = DownloadAttribution.getAnalyticsData(
830830
null,
831831
params
832832
);
833833

834834
DownloadAttribution.setRawCookie(
835-
DownloadAttribution.COOKIE_MARKETING_RAW_ID,
836-
marketing
835+
DownloadAttribution.COOKIE_ANALYTICS_RAW_ID,
836+
analytics
837837
);
838838

839839
const essential = DownloadAttribution.getRawCookie(
840840
DownloadAttribution.COOKIE_ESSENTIAL_RAW_ID
841841
);
842842

843-
DownloadAttribution.requestCombinedAuth(essential, marketing);
843+
DownloadAttribution.requestCombinedAuth(essential, analytics);
844844

845-
if (marketing.client_id_ga4) {
845+
if (analytics.client_id_ga4) {
846846
window.dataLayer.push({
847847
event: 'stub_session_set',
848-
id: marketing.session_id
848+
id: analytics.session_id
849849
});
850850
}
851851
});
@@ -855,9 +855,9 @@ const DownloadAttribution = {
855855
);
856856

857857
if (essential) {
858-
// remove marketing only
858+
// remove analytics only
859859
DownloadAttribution.removeRawCookie(
860-
DownloadAttribution.COOKIE_MARKETING_RAW_ID
860+
DownloadAttribution.COOKIE_ANALYTICS_RAW_ID
861861
);
862862
DownloadAttribution.requestCombinedAuth(essential, null);
863863
} else {

0 commit comments

Comments
 (0)