Guide

Show a GDPR consent banner by country

Only prompt for cookie consent where it's legally required, for a cleaner experience elsewhere.

1. Ask whether GDPR applies

Each result includes gdpr_required (and is_eu_member). Look the visitor up server-side when rendering the page:

curl "https://ipquery.info/api?apiKey=YOUR_API_KEY&ip=VISITOR_IP"
# -> [ { ..., "is_eu_member": true, "gdpr_required": true } ]

2. Gate the banner

If gdpr_required is true, render your consent banner and withhold non-essential cookies until the visitor accepts; otherwise load normally. This is advisory geolocation, not legal advice — combine it with your own compliance policy.

3. Don't break on errors

If the lookup fails or the IP can't be resolved, default to showing the banner so you fail safe.