and runs during HTML parse, but hubspotutk is set by js.hs-analytics.net, measured loading at ~834ms. On a first visit the cookie does not exist yet, so a single read returns nothing and the visitor gets no external ID at all — and a first visit is exactly what an ad click is. So poll briefly until HubSpot sets it. The SDK loads lazily (~4.5s) and replays a queue, so an init queued a second or two in still lands before any events are transmitted. */ (function attachExternalId() { var attempts = 0; var MAX_ATTEMPTS = 40; /* 40 x 200ms = 8s, then give up quietly */ var timer = null; function tryAttach() { var raw = getExternalId(); if (!raw) { if (++attempts >= MAX_ATTEMPTS && timer) clearInterval(timer); return; } if (timer) clearInterval(timer); sha256Hex(raw).then(function (hash) { oaiq("init", { user: { external_id_sha256: hash } }); }).catch(function () {}); } tryAttach(); /* returning visitor: immediate */ if (!getExternalId()) timer = setInterval(tryAttach, 200); })(); /* --------------------------------------------------------------------------- 2. Load the SDK off the critical path Whichever comes first: the main thread going idle after load, or the first sign of real user intent. No preconnect on purpose — a TLS handshake during LCP for a script we deliberately deferred is a net loss. Measured on clickpost.ai: load event 3614ms, SDK fetched 4508ms. ------------------------------------------------------------------------ */ var loaded = false; var INTENT = ["pointerdown", "keydown", "scroll"]; function loadSdk() { if (loaded) return; loaded = true; INTENT.forEach(function (t) { removeEventListener(t, loadSdk, { passive: true }); }); var s = document.createElement("script"); s.src = SDK; s.async = true; s.fetchPriority = "low"; document.head.appendChild(s); } INTENT.forEach(function (t) { addEventListener(t, loadSdk, { passive: true, once: true }); }); addEventListener("load", function () { window.requestIdleCallback ? requestIdleCallback(loadSdk, { timeout: 2500 }) : setTimeout(loadSdk, 1500); }, { once: true }); /* --------------------------------------------------------------------------- 3. Conversion id sha256(lowercase(email) + "|" + formId + "|" + ISO-hour), first 20 hex, "lead_" prefix. - email lowercased/trimmed so casing does not fork the id - formId keeps two different forms in the same hour from colliding - the hour bucket is only the server's fallback; the id computed here is sent to the relay verbatim, so the two paths cannot disagree even when a submit straddles an hour boundary Ads Manager's own sample omits event_id. We send it so the pixel event and the relay event collapse into one conversion instead of counting twice. ------------------------------------------------------------------------ */ function buildEventId(email, formId) { var seed = [ String(email || "").trim().toLowerCase(), String(formId || ""), new Date().toISOString().slice(0, 13) ].join("|"); return crypto.subtle.digest("SHA-256", new TextEncoder().encode(seed)).then(function (buf) { var hex = Array.prototype.map.call(new Uint8Array(buf), function (b) { return b.toString(16).padStart(2, "0"); }).join(""); return "lead_" + hex.slice(0, 20); }); } /* Guards a re-fire from the history.pushState that book-a-demo-core.js runs after submit, and from back-navigation onto the same state. */ function firedOnce(id) { try { if (sessionStorage.getItem("oaiq_" + id)) return true; sessionStorage.setItem("oaiq_" + id, "1"); return false; } catch (e) { return false; /* private mode / blocked storage: fire rather than lose it */ } } /* Path 2. keepalive lets the request finish even if the page navigates away. Failures are swallowed deliberately: a reporting call must never surface an error to someone who just submitted a form. The relay hashes the email server-side into user.emails_sha256 and adds the caller's IP and user agent, so this event carries the same match signals the pixel gets for free. */ function sendToRelay(email, formId, eventType, eventId) { try { var payload = { token: RELAY_TOKEN, email: email, form_id: formId || "", event_type: eventType, event_id: eventId, /* verbatim, so both paths always match */ source_url: location.href }; var oppref = getOppref(); if (oppref) payload.oppref = oppref; var externalId = getExternalId(); if (externalId) payload.external_id = externalId; fetch(RELAY_URL, { method: "POST", keepalive: true, headers: { "Content-Type": "application/json" }, body: JSON.stringify(payload) }).catch(function () {}); } catch (e) {} } /* Capture the email while the form is still on the page. onFormSubmitted does not reliably carry submissionValues, and by then the form may be removed. */ var lastEmail = ""; document.addEventListener("submit", function (e) { var f = e.target; if (!f || !f.querySelector) return; var i = f.querySelector('input[name="email"], input[type="email"]'); if (i && i.value) lastEmail = i.value; }, true); /* Every HubSpot form on the site reports through this one message event, so no module or theme JS needs editing to add coverage. */ window.addEventListener("message", function (e) { var d = e.data; if (!d || d.type !== "hsFormCallback" || d.eventName !== "onFormSubmitted") return; var email = (d.data && d.data.submissionValues && d.data.submissionValues.email) || lastEmail; if (!email) return; /* without an email there is no stable id to dedupe on */ var eventType = EVENT_BY_FORM[d.id] || EVENT_DEFAULT; buildEventId(email, d.id).then(function (id) { if (firedOnce(id)) return; oaiq("measure", eventType, { type: DATA_TYPE }, { event_id: id }); /* path 1 */ sendToRelay(email, d.id, eventType, id); /* path 2 */ }); }); })();

91ÊÓÆµ

Assess Your Post-Purchase Brand Readiness Start Assessment

Home > Blog >

Failed Delivery Statistics 2026: Address Errors & Delivery Costs

Failed Delivery Statistics 2026: Address Errors & Delivery Costs

Teerna Mandal
By Teerna Mandal
Sathish Loganathan
Reviewed by This article has been thoroughly reviewed, fact-checked, and compiled using comprehensive, up-to-date information provided by ClickPost — a trusted authority in logistics and eCommerce shipping solutions. Our editorial process ensures accuracy, relevance, and reliability for our readers. Sathish Loganathan

Ready to delight customers after checkout?

Trusted by 600+ brands

In this blog

    TL;DR Summary

    The most-cited US benchmark, a 2020 Loqate survey of retailers, found that 8% of first-time deliveries failed, costing an average of $17.20 each, and no newer independent US benchmark has been found. Carrier pricing has clearly changed: in 2026, a single address correction costs $25.50 at FedEx and $25.25 at UPS, and both carriers have scheduled further increases.

    • 8% of US first-time deliveries failed, as reported by retailers (Loqate, survey fielded December 2020)

    • $17.20 average cost per failed US delivery in the same survey

    • $25.50 FedEx and $25.25 UPS charge per address correction under 2026 fee schedules

    • 71% of retailers in the US, UK, and Germany agree inaccurate addresses are a primary cause of failed delivery

    • 47.7 million US adults estimated to have had a package stolen in the past year (Security.org, September 2026 survey)

    Failed delivery statistics are easy to find and hard to trust. Many figures online trace back to a few studies, some more than five years old.

    This article fixes two common problems:

    • Old data presented as new. Every statistic below shows when it was collected.

    • Different measures mixed. We keep failed attempts, delivery problems, returns, and theft separate.

    Sources include Loqate, Descartes, the USPS Office of Inspector General (OIG), Security.org, SafeWise, and the 2026 fee schedules from FedEx and UPS.

    What Is the First-Attempt Delivery Failure Rate in the US?

    No current, independent US first-attempt failure rate is publicly available. The most cited benchmark is 8%, from , based on a December 2020 survey of 304 retail executives.

    Statistic Value Who or what was measured Geography
    First-time deliveries that failed 8% Retailers reporting on their own deliveries US
    Same measure in Loqate’s earlier poll 5% Retailers US
    Retailers with more than 1 in 10 orders failing the first time 24% 304 retail executives US, UK, Germany
    Shoppers who received every order on time 13% US online shoppers US
    Shoppers with more than five fulfillment failures 12% US online shoppers US
    Consumers reporting delivery problems 66% (79% of ages 18 to 35) 8,000 consumers Europe and North America

    How to read these numbers

    • The 8% is retailer-reported, not carrier data. Loqate does not explain how responses were combined.

    • It is a 2020 figure. Use it as a historical reference point, not a 2026 rate.

    • measures any delivery problem a shopper reports, including late or damaged parcels.

    • Descartes covers Europe and North America, so it is not a US-only figure.

    • The Loqate and Descartes figures measure different things and should not be merged.

    Failed Deliveries, RTO, Delivery Problems and Theft: What Each Statistic Measures

    Published figures range from single digits to above 60% because they count different events. The table below defines each one.

    Term What it means Where it is usually recorded
    Failed delivery attempt The carrier cannot complete a stop: wrong or incomplete address, nobody available, access problem Carrier exception scans and attempt notices
    First-attempt failure rate Share of shipments not delivered on the first attempt Retailer or carrier performance data
    Return to origin (RTO) The carrier stops trying and returns the package to the shipper, also called return to sender Carrier return scans; retailer returns logs
    Consumer-reported delivery problem Any issue a shopper reports, including late, damaged, or missing parcels Consumer surveys
    Delivered but not received Tracking shows delivered, but the customer does not have the package Customer claims and support tickets
    Package theft A delivered package is taken before the recipient collects it Consumer surveys, police reports, retailer claims

    How Much Does a Failed Delivery Cost?

    The most recent published US benchmark is $17.20 per failed delivery, from . No newer independent US average was found.

    What the research shows

    • Loqate links the $17.20 to redelivery, refunds, and apology discounts.

    • The average US retailer in the sample shipped 140,792 orders a year and lost $193,730 to failed deliveries.

    • 45% of US businesses said each failure also brought a $1 to $20 chargeback.

    • Live service contacts cost $8.01 each in , against about $0.10 for self-service. This benchmark is older and not US-specific.

    What has changed since 2020

    • FedEx raised its address correction charge from $24 (2025) to $25.50 (2026).

    • UPS raised its charge from $23.50 (2025) to $25.25 (2026).

    • Because carrier fees have risen, the 2020 cost should not be read as a 2026 cost.

    Illustrative scenario: annual failed delivery cost using Loqate’s 2020 inputs

    Monthly orders Annual orders Failed deliveries at 8% Cost at $17.20 each
    1,000 12,000 960 $16,512
    10,000 120,000 9,600 $165,120
    50,000 600,000 48,000 $825,600
    100,000 1,200,000 96,000 $1,651,200
    • This table uses a 2020 failure rate and a 2020 cost. It is a planning illustration, not a 2026 measurement.
    • Your real cost depends on carriers, destinations, order values, and how often a failure becomes a refund or reshipment.

    What Do FedEx and UPS Charge for Address Corrections in 2026?

    FedEx charges $25.50 per address correction in 2026, per its . UPS charges $25.25 per package, capped at $175.25 per shipment, per its .

    Charge FedEx 2026 UPS 2026 When it applies
    Address correction $25.50 per correction $25.25 per package; max $175.25 per shipment Carrier corrects or completes an address
    Reroute or intercept $25.50 per package (Reroute of Shipment) $21 web request; $27 phone request (Delivery Intercept) Shipper or recipient redirects a package in transit
    Residential delivery $6.45 per package (Ground, Home Delivery) $6.50 per package (Ground) Delivery to a residential address
    Delivery area, residential $6.60 per package $6.55 per package Residential delivery in a designated ZIP code
    Delivery area, extended residential $8.80 per package $8.85 per package Residential delivery in an extended-area ZIP code
    Remote area, contiguous US $16.75 per package $16.50 per package Delivery in a designated remote ZIP code
    Effective from Jan 5, 2026 Dec 22, 2025

    List prices; negotiated contracts may differ

    Illustrative example 1: stacked surcharges

    • A FedEx Home Delivery package to an extended residential ZIP code pays $6.45 (residential) plus $8.80 (delivery area) = $15.25.

    • If FedEx also corrects the address, add $25.50, for $40.75 in list-price surcharges.

    • This excludes the base rate and any fuel surcharge.

    Illustrative example 2: annual correction fees

    • A brand ships 10,000 FedEx orders a month.

    • Assume 2% need an address correction. This is an assumption, not a benchmark.

    • That is 2,400 corrections a year, or $61,200 at $25.50 each.

    Myth check: the "$18 FedEx reattempt fee"

    • FedEx's 2026 schedule lists Delivery Reattempt only for U.S. Express Freight, at the greater of $97 per shipment or $0.106 per pound.

    • The $18 line in the same document is FedEx Priority Alert, a separate premium service.

    What Causes Most Failed Deliveries?

    Inaccurate addresses are the most cited cause. In , 71% of retail executives in the US, UK, and Germany said it is a primary cause of failed delivery.

    No recent neutral US study ranks every cause by share. Here is what the evidence shows for each:

    1. Address errors. 74% of retailers said bad address data causes up to a quarter of their failures. 34% did not verify customer addresses, though 83% of US retailers did.

    2. Address entry problems. 13% of smartphone shoppers struggled to enter their address (US, UK, and Germany). 56% of US consumers call it a chore.

    3. Recipient not available. Missed deliveries lead to reattempts, holds, and returns. No neutral source measures this cause's share.

    4. Theft after a delivery scan. These usually show as completed deliveries in carrier data.

    5. Carrier and network issues. Mis-sorts, damage, and peak-season strain. No public US breakdown was found.

    A note on Loqate's 39% and 41% figures: Loqate reports that inaccurate addresses lead to 39% of deliveries failing and 41% being delayed. The report does not state the base, so treat these as directional.

    Loqate's Matthew Furneaux put it:

    How Many Delivery Attempts Do Carriers Make?

    UPS says it may make up to three delivery attempts at its discretion, then returns undeliverable packages to the sender, per its .

    • FedEx: no single attempt limit appears in the 2026 fee schedule. Confirm in the FedEx Service Guide or with your account representative.

    • UPS intercept fee (2026): $21 by web, $27 by phone.

    • FedEx reroute fee (2026): $25.50 per package.

    Package Theft Statistics: How Big Is the "Delivered but Not Received" Problem?

    Package theft is large enough to distort delivery data. Security.org estimates 47.7 million US adults had a package stolen in the past year, and a  estimated losses at $5 billion to $16 billion per year.

    Source What is counted Value Method Period
    US adults who had a package stolen 47.7 million people; $7.7B in stolen goods Online survey of 3,494 US adults, three-month rate annualized Survey Sept 22 to 24, 2026
    Packages stolen from US households 104.3 million packages in about 91 million incidents Survey-based estimate 12 months before Nov 2025
    USPS OIG, citing Security.org Packages stolen At least 58 million packages Third-party survey estimate compiled by the OIG 2024
    USPS OIG, compiling third-party estimates Annual financial losses $5.2 billion to $16 billion Range across Finder, Security.org, and SafeWise estimates 2023 to 2024

    Why these numbers differ

    • Security.org counts people. SafeWise counts packages. The OIG compiles other estimates.

    • The OIG notes that theft, misdelivery, and false claims are hard to separate.

    • Retailers often absorb replacement costs. One national retailer told the OIG it moved business away from carriers because lost package claims grew too high.

    • Practical step: track "delivered but not received" claims as their own metric, not just carrier failure data.

    How Do Failed Deliveries Affect Customer Retention?

    In a , 57% said they would avoid a retailer after a negative delivery experience. This measures stated intent, not actual churn.

    • 57% of consumers in the US, UK, and Germany would be reluctant to reuse a retailer after a fulfillment failure (Loqate, 2021).

    • 60% of retailers say customers blame them, not the courier, for delivery issues (Loqate).

    • 41% of consumers blamed the retailer for late orders; 32% blamed the courier (Loqate).

    • 12% would post a negative review and 9% would complain on social media (Loqate).

    • 63% of consumers with a delivery problem took action that hurt the retailer or carrier (, Europe and North America).

    What Changes in 2027?

    Delivery volume and carrier prices are both rising. US retail e-commerce sales reached $340.2 billion in Q2 2026, according to the .

    • That was 17.1% of total retail sales.

    • It was 12.2% higher than in Q2 2025.

    • FedEx and UPS have both announced 5.9% average rate increases for 2027.

    Item Figure Effective date Status Source
    UPS daily rate increase 5.9% average net increase Dec 21, 2026 Announced by UPS
    UPS address correction $27.50 per package, up from $25.25 Dec 21, 2026 Reported from UPS 2027 rate preview ;
    FedEx list rate increase 5.9% average increase Jan 4, 2027 Announced by FedEx ;
    FedEx address correction $27.00 per correction, up from $25.50 Jan 4, 2027 Confirmed in FedEx 2027 surcharge and fee schedule
    US e-commerce revenue projection $1.88 trillion by 2029, from $1.22 trillion in 2024 2029 Projection, not a current measurement , citing Statista
    • The UPS $27.50 figure comes from parcel audit firms reviewing UPS’s 2027 preview. UPS’s rates page links to that preview, but no official UPS document confirms the fee.

    • The Statista projection uses a different revenue definition than Census data, so you shouldn't compare the two directly.

    Address correction fees are rising faster than average rates

    • UPS’s address correction fee is scheduled to rise 8.91%, from $25.25 to $27.50 per package, on December 21, 2026, according to .

    • That is 3.01 percentage points above UPS’s .

    • FedEx’s fee rises 5.88%, from $25.50 to $27, on January 4, 2027, per its .

    • Takeaway: give address-related fees their own line in your shipping budget.

    Younger shoppers report more delivery problems

    • 79% of consumers aged 18 to 35 reported delivery problems, vs 66% overall (, Europe and North America).

    • 43% of under-35s increased online spending year on year.

    Apartment residents face higher theft risk

    • 10% of apartment residents had a package stolen in the past three months, vs. 3% in single-family homes ().

    • 37% of all respondents hesitated to order online because of theft concerns.

    Secure pickup options are expanding

    • USPS offered more than 500 Smart Locker locations as of summer 2024 ().

    • The OIG lists lockers, scheduled delivery, and pickup points as key defenses against porch theft.

    How Can Ecommerce Brands Reduce Failed Deliveries?

    Start with failures that appear on carrier invoices, since they are easiest to measure. These steps run from checkout to delivery:

    1. Validate addresses at checkout, with separate fields for apartment and suite numbers.

    2. Let customers correct their address before the label is created, when no carrier fee applies.

    3. Send shipping and out-for-delivery notifications so recipients can prepare.

    4. Offer lockers, access points, or store pickup in apartments and high-theft areas.

    5. Review carrier invoices monthly for corrections, reroutes, and residential charges. Dispute corrections where the address was already right.

    6. Track first-attempt failures, "delivered but not received" claims, and WISMO queries as separate metrics.

    7. Compare carriers by destination, since area surcharges differ by carrier and service.

    Where ClickPost fits

    ClickPost's US post-purchase platform supports several of these steps.

    Before the order ships

    • lets shoppers update details such as the shipping address themselves.

    • Address validation is built into the editing flow.

    • Merchants can set an editing window that matches their fulfilment cutoff.

    After the label is created

    • An address change is no longer a simple edit and may trigger carrier correction or reroute charges.

    • Branded tracking pages and proactive delay and exception alerts keep customers informed.

    • AI-assisted NDR resolution helps teams act faster on delivery exceptions.

    These tools won't prevent every failed delivery or stop theft. They help brands catch more preventable problems before carrier fees and refunds apply.

    Failed Delivery Statistics at a Glance

    Statistic Value Measured Geography Period Source
    First-time deliveries that failed 8% Retailer-reported US Dec 2020 survey Loqate
    Average cost per failed delivery 17 Retailer-reported US Dec 2020 survey Loqate
    Retailers with more than 1 in 10 orders failing first time 24% Retail executives US, UK, Germany Dec 2020 Loqate
    Retailers agree bad addresses are a primary cause 71% Retail executives US, UK, Germany Dec 2020 Loqate
    US retailers verifying addresses at checkout 83% Retail executives US Dec 2020 Loqate
    Consumers who would avoid a retailer after a bad delivery 57% 1,200 consumers US 2020 Loqate (GBG)
    Consumers reporting delivery problems 66% 8,000 consumers Europe and North America Q1 2025 Descartes
    FedEx address correction charge $25.50 Published list price US 2026 FedEx
    UPS address correction charge $25.25 Published list price US 2026 UPS
    US adults who had a package stolen 47.7 million Annualized survey estimate US 12 months to Sept 2026
    Packages stolen 104.3 million Survey-based estimate US 12 months to Nov 2025 SafeWise
    Annual package theft losses $5.2B to $16B Range of third-party estimates US 2023 to 2024 USPS OIG
    Cost per live service contact $8.01 Poll of service leaders Not US-specific 2019 Gartner
    Ecommerce share of US retail sales 17.10% Seasonally adjusted US Q2 2026 US Census Bureau

    The Bottom Line

    • The best-known figures, 8% and $17.20, come from a survey fielded in December 2020. No independent US study has replaced them.

    • Carrier pricing is easier to measure: one address correction now costs more than Loqate's entire average cost per failure.

    • FedEx and UPS have both scheduled further increases for 2027.

    Your next step: pull 90 days of carrier invoices, count address corrections, reroutes, and intercepts, then add "delivered but not received" refunds. Compare that total with your order volume to get your own baseline.

    Failed Delivery Statistics FAQs

    What is the first-attempt delivery failure rate in the US?

    There is no current, independently measured US rate. The most cited benchmark is Loqate's December 2020 retailer survey, which found 8% of US first-attempt deliveries failed, up from 5% in its 2017 poll. Treat 8% as a historical, retailer-reported reference point rather than a 2026 rate.

    What are the most common reasons deliveries fail?

    Retailers most often cite inaccurate or incomplete addresses. In Loqate's 2020 survey, 71% of retail executives in the US, UK, and Germany said inaccurate addresses are a primary cause of failed deliveries. Other main causes include recipients not being available, theft after a delivery scan, and carrier errors such as damage or mis-sorting.

    How much does a failed delivery cost?

    The most recent published US benchmark is $17.20 per failed delivery, from Loqate's 2020 retailer survey, covering costs such as redelivery, refunds, and apology discounts. No newer independent US average was found. Carrier charges linked to failures, including address corrections, have increased since then, so the 2020 figure should not be read as a 2026 cost.

    How much do FedEx and UPS charge for address corrections?

    In 2026, FedEx charges $25.50 per address correction, and UPS charges $25.25 per package, capped at $175.25 per shipment. Both charge when they correct or complete an incorrect or incomplete address. FedEx’s fee rises to per correction on January 4, 2027. UPS’s fee is scheduled to rise to on December 21, 2026, according to parcel audit firms reviewing its 2027 rate preview.

    How many delivery attempts do carriers make?

    UPS states that it may make up to three delivery attempts at its discretion, after which it returns undeliverable packages to the sender. FedEx does not state a single-attempt limit in its 2026 fee schedule, so shippers should confirm the current FedEx policy in its service guide or with their account representative.

    What is the difference between a failed delivery and an RTO?

    A failed delivery is an unsuccessful attempt to deliver a package. Return to origin (RTO), also called return to sender, happens when the carrier stops attempting delivery and sends the package back to the shipper. An RTO usually follows one or more failed attempts, and the shipper typically absorbs the return and any reshipment or refund.

    Is package theft counted as a failed delivery?

    Usually not. When a package is stolen after the carrier scans it as delivered, carrier records typically show a completed delivery. The USPS Office of Inspector General notes that available data makes it hard to separate theft, loss, and misdelivery, so brands should track "delivered but not received" claims separately from carrier failure data.

    How can ecommerce brands reduce failed deliveries?

    Start with address quality. Loqate's 2020 survey found 34% of retailers in the US, UK, and Germany did not verify shipping addresses. Validate addresses at checkout, allow address edits before fulfillment, send shipping and delivery notifications, offer secure pickup options in high-theft areas, and review carrier invoices monthly for correction charges.

    The Post-Purchase Experience Platform

    Momentum Leader - G2 Users Most Likely To Recommend - G2 Best Results Mid-Market - G2
    . window.disableHubSpotCookieBanner = true; function killNative() { var n = document.getElementById("hs-eu-cookie-confirmation"); if (n && n.parentNode) { n.parentNode.removeChild(n); return true; } return false; } killNative(); if (window.MutationObserver) { var mo = new MutationObserver(function () { killNative(); }); mo.observe(document.documentElement, { childList: true, subtree: true }); setTimeout(function () { mo.disconnect(); }, 15000); } var COOKIE = "cp_cookie_consent"; var EU = ["at","be","bg","hr","cy","cz","dk","ee","fi","fr","de","gr","hu","ie","it","lv","lt","lu","mt","nl","pl","pt","ro","sk","si","es","se","gb","uk","is","li","no","ch"]; function readCookie(nm) { var m = document.cookie.match(new RegExp("(?:^|; )" + nm + "=([^;]*)")); return m ? decodeURIComponent(m[1]) : null; } function writeCookie(nm, val, days) { var d = new Date(); d.setTime(d.getTime() + (days * 864e5)); document.cookie = nm + "=" + encodeURIComponent(val) + ";expires=" + d.toUTCString() + ";path=/;SameSite=Lax" + (location.protocol === "https:" ? ";Secure" : ""); } function stored() { var raw = readCookie(COOKIE); if (!raw) return null; try { var o = JSON.parse(raw); if (typeof o.analytics === "boolean") return o; } catch (e) {} return null; } function apply(state, revoke) { window._hsp = window._hsp || []; window._hsp.push(["setHubSpotConsent", { analytics: !!state.analytics, advertisement: !!state.advertisement, functionality: !!state.functionality }]); if (revoke && !state.analytics && !state.advertisement && !state.functionality) { window._hsp.push(["revokeCookieConsent"]); } window.dataLayer = window.dataLayer || []; window.dataLayer.push({ event: "cp_cookie_consent", cp_consent_analytics: !!state.analytics, cp_consent_advertisement: !!state.advertisement, cp_consent_functionality: !!state.functionality }); document.documentElement.setAttribute("data-cp-consent", "set"); } function inScope(banner) { if (banner.getAttribute("data-scope") !== "eu_only") return true; var geo = (document.body.getAttribute("data-geo_location") || "").toLowerCase(); if (!geo) return true; return EU.indexOf(geo) !== -1; } function init(banner) { var days = parseInt(banner.getAttribute("data-days"), 10) || 180; var prefs = banner.querySelector("[data-cpcb-prefs]"); var compact = banner.querySelector('[data-cpcb-actions="compact"]'); var expanded = banner.querySelector('[data-cpcb-actions="expanded"]'); var toggles = banner.querySelectorAll("[data-cpcb-toggle]"); function show() { banner.hidden = false; requestAnimationFrame(function () { banner.classList.add("is-visible"); }); } function hide() { banner.classList.remove("is-visible"); setTimeout(function () { banner.hidden = true; }, 300); } function collapse() { if (!prefs) return; prefs.hidden = true; if (expanded) expanded.hidden = true; if (compact) compact.hidden = false; } function expand() { if (!prefs) return; prefs.hidden = false; if (compact) compact.hidden = true; if (expanded) expanded.hidden = false; } function paint(state) { Array.prototype.forEach.call(toggles, function (t) { var key = t.getAttribute("data-cpcb-toggle"); if (key === "necessary") { t.setAttribute("aria-checked", "true"); return; } t.setAttribute("aria-checked", state[key] ? "true" : "false"); }); } function fromToggles() { var state = { analytics: false, advertisement: false, functionality: false }; Array.prototype.forEach.call(toggles, function (t) { var key = t.getAttribute("data-cpcb-toggle"); if (key in state) state[key] = t.getAttribute("aria-checked") === "true"; }); return state; } function commit(state, revoke) { writeCookie(COOKIE, JSON.stringify({ analytics: !!state.analytics, advertisement: !!state.advertisement, functionality: !!state.functionality, v: 1, ts: Date.now() }), days); apply(state, revoke); hide(); } Array.prototype.forEach.call(toggles, function (t) { if (t.disabled) return; t.addEventListener("click", function () { t.setAttribute("aria-checked", t.getAttribute("aria-checked") === "true" ? "false" : "true"); }); }); banner.addEventListener("click", function (e) { if (!e.target || !e.target.closest) return; var btn = e.target.closest("[data-cpcb-action]"); if (!btn) return; var action = btn.getAttribute("data-cpcb-action"); if (action === "customise") { expand(); return; } if (action === "accept") { commit({ analytics: true, advertisement: true, functionality: true }, false); return; } if (action === "reject") { commit({ analytics: false, advertisement: false, functionality: false }, true); return; } if (action === "save") { commit(fromToggles(), true); return; } }); var existing = stored(); if (existing) { apply(existing, false); paint(existing); collapse(); } else if (!inScope(banner)) { // Out of the consent-required region: implied consent, banner never shown. commitSilently(); } else { collapse(); show(); } function commitSilently() { var all = { analytics: true, advertisement: true, functionality: true }; writeCookie(COOKIE, JSON.stringify({ analytics: true, advertisement: true, functionality: true, v: 1, ts: Date.now(), implied: true }), days); apply(all, false); } // Public re-open hook for a footer "Cookie settings" link. window.cpCookieBanner = window.cpCookieBanner || {}; window.cpCookieBanner.open = function () { var s = stored() || { analytics: false, advertisement: false, functionality: false }; paint(s); expand(); show(); }; } function boot() { var banners = document.querySelectorAll("[data-cpcb]"); if (!banners.length) return; init(banners[0]); document.addEventListener("click", function (e) { if (!e.target || !e.target.closest) return; var trigger = e.target.closest("[data-cp-cookie-settings]"); if (!trigger) return; e.preventDefault(); if (window.cpCookieBanner && window.cpCookieBanner.open) window.cpCookieBanner.open(); }); } if (document.readyState === "loading") { document.addEventListener("DOMContentLoaded", boot); } else { boot(); } })();