in media/js/base/stub-attribution/stub-attribution.js [628:679]
StubAttribution.init = function (successCallback, timeoutCallback) {
var data = {};
if (!StubAttribution.meetsRequirements()) {
return;
}
// Support custom callback functions for success and timeout.
if (typeof successCallback === 'function') {
StubAttribution.successCallback = successCallback;
}
if (typeof timeoutCallback === 'function') {
StubAttribution.timeoutCallback = timeoutCallback;
}
/**
* If cookie already exists, update download links on the page,
* else make a request to the service if within attribution rate.
*/
if (StubAttribution.hasCookie()) {
data = StubAttribution.getCookie();
StubAttribution.updateBouncerLinks(data);
// As long as the user is not already on the automatic download page,
// make the XHR request to the stub authentication service.
} else if (!StubAttribution.isFirefoxDownloadThanks()) {
// Wait for GA4 to load and return client IDs
StubAttribution.waitForGoogleAnalyticsThen(function () {
// get attribution data
data = StubAttribution.getAttributionData();
if (
data &&
StubAttribution.withinAttributionRate() &&
StubAttribution.hasValidData(data)
) {
// if data is valid and we are in sample rate:
// request authentication from stub attribution service
StubAttribution.requestAuthentication(data);
// Send the session ID to GA4
if (data.client_id_ga4) {
window.dataLayer.push({
event: 'stub_session_set',
id: data.session_id
});
}
}
});
}
};