var onPreferenceExpressedOrNotNeededCallback = function(prefs) { var isPrefEmpty = !prefs || Object.keys(prefs).length === 0; var consent = isPrefEmpty ? _iub.cs.api.getPreferences() : prefs; var shopifyPurposes = { "analytics": [4, 's'], "marketing": [5, 'adv'], "preferences": [2, 3], "sale_of_data": ['s', 'sh'], } var expressedConsent = {}; Object.keys(shopifyPurposes).forEach(function(purposeItem) { var purposeExpressed = null shopifyPurposes[purposeItem].forEach(item => { if (consent.purposes && typeof consent.purposes[item] === 'boolean') { purposeExpressed = consent.purposes[item]; } if (consent.uspr && typeof consent.uspr[item] === 'boolean' && purposeExpressed !== false) { purposeExpressed = consent.uspr[item]; } }) if (typeof purposeExpressed === 'boolean') { expressedConsent[purposeItem] = purposeExpressed; } }) window.Shopify.customerPrivacy.setTrackingConsent(expressedConsent, function() {}); } if (typeof _iub.csConfiguration.callback === 'object') { _iub.csConfiguration.callback.onPreferenceExpressedOrNotNeeded = onPreferenceExpressedOrNotNeededCallback; } else { _iub.csConfiguration.callback = { onPreferenceExpressedOrNotNeeded: onPreferenceExpressedOrNotNeededCallback }; }
Vai al contenuto