---
updatedAt: 2025-12-15T10:59:16.000Z
agentTools:
  projectIndex: https://developer.onetrust.com/onetrust/llms.txt
---

# Custom Geolocation Integration

OneTrust Cookie Compliance leverages a geolocation service that, paired with the configurable Geolocation Rules in the application, allows flexibility in which banner and preference center are displayed to users when navigating to your website. This is done by leveraging CloudFlare to perform a reverse IP lookup that will return the general location of the user (approximately at the city level). The location is not stored and is only used to determine the applicable Geolocation Rule.

[Cloudflare Support](https://support.cloudflare.com/hc/en-us/articles/200168236-Configuring-Cloudflare-IP-Geolocation)

If you already use a geolocation service for other functions on your website and want to be certain that whatever location is returned is consistent across the site visitor's browsing experience, you can integrate your banner script with your existing service.

## How It Works

The banner script calls a geolocation service to return the country, state and region values of the user accessing the website. These values are then passed into the functions determining which Geolocation Rule is being followed. The following variables reference the stored values:

* stateCode
* countryCode
* regionCode

For custom geolocation integrations, an additional variable is added into the banner script that includes the three geolocation values. When a custom geolocation service is used, uncomment this section to initialize the OneTrust.geolocationResponse array with the values provided by your geolocation service.

> **Note**
>
> This variable must be set **before** the OneTrust script executes.

```javascript
<script type="text/javascript">
  // uncomment for customGeolocation        
  // var OneTrust = {        
  //     geolocationResponse: {        
  //         stateCode: 'KA',        
  //         countryCode: 'IN',        
  //         regionCode: 'EU', // Optional parameter        
  //     }        
  // };    
</script>
```

A `boolean` check is then used to evaluate the `OneTrust.geolocationResponse` variable and utilize the geolocation values from your geolocation service instead of calling OneTrust's service. If any invalid codes are passed, the `geolocationResponse` value will not be used, instead there is a *default* rule group that is configured in the admin console.

# Sibling pages

* [Web CMP JavaScript Methods](https://developer.onetrust.com/onetrust/docs/javascript-api.md)
* [Web CMP Events Guide](https://developer.onetrust.com/onetrust/docs/javascript-events-guide.md)
* [Display Preference Center on Script Load](https://developer.onetrust.com/onetrust/docs/display-preference-center.md)
* [AMP Integration](https://developer.onetrust.com/onetrust/docs/amp-integration.md)
* [Cookie Consent Support for AMP Websites](https://developer.onetrust.com/onetrust/docs/cookie-consent-support-for-amp-websites.md)
* [Configuring a Content Security Policy with OneTrust CDN](https://developer.onetrust.com/onetrust/docs/content-security-policy-cdn.md)
* [IAB CCPA: Configuring the US Privacy String](https://developer.onetrust.com/onetrust/docs/iab-ccpa-us-privacy-string.md)
* [IAB TCF Developer Guide](https://developer.onetrust.com/onetrust/docs/iab-tcf-developer-guide.md)
* [Using TCF with Header Bidding (TCF Stub)](https://developer.onetrust.com/onetrust/docs/using-tcf-with-header-bidding.md)
* [Using TCF with Prebid](https://developer.onetrust.com/onetrust/docs/using-tcf-with-prebid.md)
* [Single Page Applications](https://developer.onetrust.com/onetrust/docs/single-page-applications.md)
* [Multi-Touch Consent](https://developer.onetrust.com/onetrust/docs/multi-touch-consent.md)
* [Google Consent Mode](https://developer.onetrust.com/onetrust/docs/using-google-consent-mode.md)
* [Custom Common CSS and JavaScript](https://developer.onetrust.com/onetrust/docs/common-custom-css.md)
* [Custom Common HTML](https://developer.onetrust.com/onetrust/docs/custom-common-html.md)
* [Server Side Rendering Performance & Availability](https://developer.onetrust.com/onetrust/docs/server-side-rendering-performance-availability.md)
* [PRA/DSAR - Web CMP Opt Out](https://developer.onetrust.com/onetrust/docs/dsarpra-web-cmp-opt-out.md)
* [Bulk Domain Management](https://developer.onetrust.com/onetrust/docs/bulk-domain-management.md)
* [Cookie Consent Integration with Google Tag Gateway for Advertisers](https://developer.onetrust.com/onetrust/docs/cookie-consent-integration-with-google-tag-gateway-for-advertisers.md)