Two developer integrations for TuneSera Pro analytics: connecting a cookie consent manager, and supplying listener countries from your own GeoIP source.
Pro feature. This feature needs TuneSera Pro with an active license. Get TuneSera Pro
Consent API#
Turn on Require consent before tracking in Settings → Analytics. TuneSera then collects nothing until you call:
// Visitor accepted analytics
window.TuneSeraAnalytics?.setConsent(true);
// Visitor declined or withdrew consent: stops collection and clears the stored ID
window.TuneSeraAnalytics?.setConsent(false);Call it after the analytics script has loaded, for example from your consent manager’s “statistics accepted” callback. No requests are sent before consent in this mode.
Listener country provider#
By default, listener country is recorded automatically only when your site runs behind Cloudflare or CloudFront. Otherwise it shows as Unknown. To use your own trusted source, such as a GeoIP database on your server, add a filter:
add_filter( 'tunesera_pro_analytics_country', function ( $country, $request ) {
// Look up the visitor's country with your server's GeoIP provider
// and return a verified two-letter ISO code, e.g. 'GB'.
return $country;
}, 10, 2 );Only use headers from a proxy you trust. Headers sent directly by visitors can be faked. TuneSera never stores raw IP addresses and never contacts an external GeoIP service for analytics.