Skip to content

Commit e8bc444

Browse files
oschwaldclaude
andcommitted
Add tracking_token documentation for explicit device linking
Update API request/response docs and expand the device tracking page with explicit device linking guidance and examples. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 082cb60 commit e8bc444

File tree

4 files changed

+120
-1
lines changed

4 files changed

+120
-1
lines changed

content/minfraud/api-documentation/requests.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ transaction.
198198
"ip_address": "2001:db8::ff00:42:8329",
199199
"session_age": 3600.5,
200200
"session_id": "c2ffa1b7-f5c5-4702-beb2-4254794fe391",
201+
"tracking_token": "abc123...",
201202
"user_agent": "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2272.89 Safari/537.36"
202203
}
203204
```
@@ -234,6 +235,12 @@ transaction.
234235

235236
[Learn more about the /device/session\_id input on our Knowledge Base.](https://support.maxmind.com/knowledge-base/articles/device-inputs-minfraud#session-information)
236237
{{</minfraud-schema-row>}}
238+
239+
{{< minfraud-schema-row key="tracking_token" type="request" valueType="string" valueTypeNote="max length: 255" >}}
240+
The token returned by the [Device Tracking Add-On](/minfraud/track-devices) `trackDevice()` function, used for explicit device linking. When provided, this token enables high-confidence device matching that does not rely on IP address alone.
241+
242+
[Learn more about explicit device linking on our device tracking page.](/minfraud/track-devices#explicit-device-linking)
243+
{{</minfraud-schema-row>}}
237244
{{</ schema-table >}}
238245

239246
<!-- prettier-ignore-end -->

content/minfraud/api-documentation/responses.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1395,6 +1395,8 @@ this array for issues when integrating the web service.
13951395
| `SHIPPING_COUNTRY_NOT_FOUND` | The shipping country could not be found in our database. This may impact our ability to provide accurate distance calculations. |
13961396
| `SHIPPING_POSTAL_NOT_FOUND` | The shipping postal code could not be found in our database. This may impact our ability to provide accurate distance calculations. |
13971397
| `SHIPPING_REGION_NOT_FOUND` | The shipping region could not be found in our database. This may impact our ability to provide accurate distance calculations. |
1398+
| `TRACKING_TOKEN_INVALID` | The tracking token provided was invalid or malformed. |
1399+
| `TRACKING_TOKEN_NOT_FOUND` | The tracking token provided was not found on our system. |
13981400
{{</minfraud-schema-row>}}
13991401

14001402
{{< minfraud-schema-row key="warning" type="response" valueType="string" valueTypeNote="max length: 255" score="true" insights="true" factors="true" >}}

content/minfraud/track-devices.md

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ and provides direct access to the tracking result.
7777
accountId: MAXMIND_ACCOUNT_ID,
7878
})
7979
)
80+
.then(({ trackingToken }) => {
81+
// Store the tracking token to include in your minFraud API request
82+
console.log('Tracking token:', trackingToken);
83+
})
8084
.catch((e) => console.error(e));
8185
</script>
8286
```
@@ -93,14 +97,119 @@ npm install @maxmind/device-tracking
9397
```javascript
9498
import { trackDevice } from '@maxmind/device-tracking';
9599

96-
const result = await trackDevice({
100+
const { trackingToken } = await trackDevice({
97101
accountId: MAXMIND_ACCOUNT_ID,
98102
});
103+
104+
// Store the tracking token to include in your minFraud API request
105+
console.log('Tracking token:', trackingToken);
99106
```
100107

101108
See the [package README](https://github.com/maxmind/device-tracking#readme) for
102109
full API documentation.
103110

111+
## Explicit device linking
112+
113+
By default, the minFraud service matches devices using IP address. This works
114+
well in most cases, but IP-based matching can be less reliable when multiple
115+
users share the same IP address. Common scenarios include:
116+
117+
- **Shared or corporate IPs** where many employees or users share a single
118+
public IP address.
119+
- **Carrier-Grade NAT (CGNAT)** where an ISP assigns the same public IP to
120+
many subscribers.
121+
- **VPNs** where multiple users route traffic through the same VPN endpoint.
122+
123+
Explicit device linking solves this by using a `tracking_token` to match devices
124+
with high confidence, independent of IP address.
125+
126+
### How it works
127+
128+
The `trackDevice()` function returns a Promise that resolves to an object
129+
containing a `trackingToken` string. When you pass this token to the minFraud
130+
API in the
131+
[`/device/tracking_token`](/minfraud/api-documentation/requests#schema--request--device)
132+
field, the service uses it to match the device directly. When a valid token is
133+
found, the device is matched with high confidence regardless of IP address
134+
changes.
135+
136+
### Implementation steps
137+
138+
1. Call `trackDevice()` on the client side and capture the returned
139+
`trackingToken`.
140+
2. Pass the token to your backend (e.g., via a hidden form field, session
141+
storage, or API call).
142+
3. Include the token in your minFraud API request's `device` object as
143+
`tracking_token`.
144+
145+
#### Web (module snippet)
146+
147+
```html
148+
<script type="module">
149+
import('https://device.maxmind.com/js/device-module.js')
150+
.then(({ trackDevice }) =>
151+
trackDevice({
152+
accountId: MAXMIND_ACCOUNT_ID,
153+
})
154+
)
155+
.then(({ trackingToken }) => {
156+
// Send the tracking token to your backend
157+
document.getElementById('tracking-token').value = trackingToken;
158+
})
159+
.catch((e) => console.error(e));
160+
</script>
161+
```
162+
163+
On your backend, include the token in the minFraud API request:
164+
165+
```json
166+
{
167+
"device": {
168+
"ip_address": "2001:db8::ff00:42:8329",
169+
"tracking_token": "token-value-from-client"
170+
}
171+
}
172+
```
173+
174+
#### Web (npm package)
175+
176+
```javascript
177+
import { trackDevice } from '@maxmind/device-tracking';
178+
179+
const { trackingToken } = await trackDevice({
180+
accountId: MAXMIND_ACCOUNT_ID,
181+
});
182+
183+
// Send the tracking token to your backend for inclusion in the minFraud request
184+
await fetch('/your-api/transaction', {
185+
method: 'POST',
186+
headers: { 'Content-Type': 'application/json' },
187+
body: JSON.stringify({ trackingToken }),
188+
});
189+
```
190+
191+
### Token handling
192+
193+
- The tracking token is an **opaque string**. Do not parse it or make
194+
assumptions about its format, as the format may change without notice.
195+
- Tokens should be treated as **transient**. Generate a fresh token for each
196+
session or transaction rather than storing tokens long-term.
197+
198+
### Content Security Policy (CSP) requirements
199+
200+
If your site uses a Content Security Policy, you will need to add the following
201+
directives to allow the device tracking script to load and communicate with
202+
MaxMind's servers:
203+
204+
- `script-src`: `device.maxmind.com`
205+
- `connect-src`: `d-ipv4.mmapiws.com`, `d-ipv6.mmapiws.com`
206+
207+
### Custom hostname
208+
209+
You can configure a custom `hostname` option when calling `trackDevice()` to
210+
serve the device tracking script from your own domain. This can help bypass
211+
ad-blockers that may block requests to third-party domains.
212+
104213
## Cookie and web storage usage
105214

106215
The device tracking add-on uses cookies and local storage as methods of

stopwords.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ cfif
3232
cfloop
3333
cfoutput
3434
cfset
35+
CGNAT
3536
Chūō
3637
Clojars
3738
Comcel

0 commit comments

Comments
 (0)