Get started with TrustCookie in minutes
Add TrustCookie to your website in just 2 lines of code
Add this code before the closing </body> tag of your website:
<!-- TrustCookie Consent Banner -->
<script src="https://api.trustcookie.com/cdn/trustcookie.min.js"></script>
<script>
TrustCookie.init({
apiKey: 'YOUR_API_KEY_HERE',
privacyNoticeVersion: 'V1.0',
collectionPointId: 'homepage_banner',
purposes: [
{ id: 'P_NECESSARY', name: 'Essential Cookies', required: true },
{ id: 'P_ANALYTICS', name: 'Analytics & Performance' },
{ id: 'P_MARKETING', name: 'Marketing & Advertising' }
]
});
</script>Get your API key from the TrustCookie console:
YOUR_API_KEY_HERE with your actual key| Option | Type | Description |
|---|---|---|
apiKey | string | Your website's API key (required) |
privacyNoticeVersion | string | Version of your privacy policy |
collectionPointId | string | Where consent is collected (e.g., homepage_banner) |
purposes | array | List of consent purposes |
position | string | 'bottom' or 'top' (default: bottom) |
primaryColor | string | Accept button color (default: #2563eb) |
secondaryColor | string | Reject button color (default: #6b7280) |
TrustCookie.init({
apiKey: 'YOUR_API_KEY',
primaryColor: '#059669', // Green
secondaryColor: '#dc2626', // Red
// ... other options
});TrustCookie.init({
apiKey: 'YOUR_API_KEY',
position: 'top',
// ... other options
});TrustCookie.init({
apiKey: 'YOUR_API_KEY',
text: {
b: 'We use cookies to enhance your experience.',
a: 'Accept All',
r: 'Reject All',
c: 'Customize',
s: 'Save Preferences',
q: '(Required)'
},
// ... other options
});TrustCookie.init({
apiKey: 'YOUR_API_KEY',
purposes: [...],
onAccept: function(consent) {
// Load analytics if accepted
var analytics = consent.consents.find(c =>
c.purpose_id === 'P_ANALYTICS' &&
c.consent_status === 'Opt-In'
);
if (analytics) {
// Load Google Analytics
loadAnalytics();
}
},
onReject: function(consent) {
console.log('User rejected consent');
}
});