Purpose
Retrieve all available tracking details for a Maersk shipment identified by its tracking number.
When to Use
Use when the caller provides a Maersk tracking number and wants its current status, events, route, dates, references, or other tracking-page details.
Workflow
- Construct and navigate directly to
https://www.maersk.com/tracking/{tracking-number}withwaitUntil: "domcontentloaded". - Wait up to 5 seconds for asynchronous tracking content to render.
- If a cookie-consent overlay blocks the page, activate the visible
button[aria-label="Essential only"]; otherwise do not interact with consent controls. - In one page evaluation, run this extractor on the loaded tracking page:
(() => {
const visible = (el) => {
if (!el) return false;
const s = getComputedStyle(el),
r = el.getBoundingClientRect();
return (
s.display !== "none" &&
s.visibility !== "hidden" &&
r.width > 0 &&
r.height > 0
);
};
const clean = (s) => (s || "").replace(/\\s+/g, " ").trim();
const root = document.querySelector('main,[role="main"]') || document.body;
const text = (el) => clean(el.innerText || el.textContent);
const fields = [...root.querySelectorAll("dl")].filter(visible).flatMap((dl) => {
const out = [];
let key = null;
[...dl.children].forEach((el) => {
if (!visible(el)) return;
if (el.matches("dt")) key = text(el);
else if (el.matches("dd") && key) {
out.push({ label: key, value: text(el) });
key = null;
}
});
return out;
});
const tables = [...root.querySelectorAll("table")]
.filter(visible)
.map((table) => ({
headers: [...table.querySelectorAll("thead th")].map(text),
rows: [...table.querySelectorAll("tbody tr")]
.filter(visible)
.map((tr) => [...tr.querySelectorAll("th,td")].map(text))
.filter((row) => row.some(Boolean)),
}))
.filter((t) => t.headers.length || t.rows.length);
const headings = [...root.querySelectorAll("h1,h2,h3,h4,h5,h6")]
.filter(visible)
.map(text)
.filter(Boolean);
const sections = [...root.querySelectorAll('section,article,[role="region"]')]
.filter(visible)
.map((el) => ({
heading: text(el.querySelector('h1,h2,h3,h4,h5,h6,[role="heading"]')),
text: text(el),
}))
.filter((x) => x.text);
return {
url: location.href,
title: document.title,
headings,
fields,
tables,
sections,
pageText: text(root),
};
})();- If the tracking page fails to expose result content, the page-backed service endpoint observed for Maersk tracking is
https://api.maersk.com/synergy/tracking/{tracking-number}?operator=MAEU. Navigate to it only as a fallback and return its parsed JSON response, preserving all nested status, milestone, routing, and reference data.
Site-Specific Gotchas
- Maersk supports a direct tracking route of the form
/tracking/{tracking-number}; use it instead of visiting the homepage and filling the form. - Category-specific routes use
/tracking/{tracking-type}/{tracking-number}. Observed category paths include/tracking/air,/tracking/parcel,/tracking/lcl, and/tracking/ocean; use a category-specific route only when the tracking type is known. The generic route is preferred because it avoids category selection. - The tracking-type control is a custom
mc-select-nativecomponent with its native<select>inside a shadow root. If category selection is unavoidable, accessdocument.querySelector('mc-select-native').shadowRoot.querySelector('select')and dispatch composedinputandchangeevents. Direct tracking-number URLs avoid manipulating this control. - The tracking input and search button may likewise be custom
mc-inputandmc-buttonelements whose native controls are inside shadow roots. Direct URLs avoid needing to fill or click them. - Cookie consent may appear before the result; the useful non-destructive option is the button labelled
Essential only. - Tracking content may render asynchronously after navigation, so allow a short render wait before extraction.
- A same-site Maersk API fallback has been observed at
/synergy/tracking/{tracking-number}?operator=MAEU; treat the operator parameter as site-specific and preserve the complete JSON rather than flattening it. - The DOM extractor preserves structured definition-list fields and tables as well as visible headings, section cards, and complete main-content text, covering mixed status, milestone, routing, and reference layouts.
Expected Output
Return an object containing the final URL, page title, visible headings, label/value fields, table headers and rows, section text, and complete visible tracking-page text. Include shipment status, milestones, locations, dates, references, vessel or transport information, and routing details when available. If the API fallback is used, return its complete parsed JSON payload as the tracking data.