Help automatically triggerring the cookies-by-category selection modal

Hi all, my customer wants to automatically trigger the cookies-by-category selection modal on page load for a specific “Privacy Preferences” page, similar to HubSpot’s own privacy site. They are looking to provide a better user experience by skipping the initial consent banner and going straight to granular opt-out settings.

Roadblock: Standard _hsp.push(['showBanner']) API calls are not firing correctly on load, even with a setTimeout delay. As the request involves custom JavaScript implementation to modify standard banner behavior, it has been deemed out of scope for Technical Support.

I’m posting on her behalf. Is someone able to help her?

Hi @SBarkley ,

This is a tricky one because the `_hsp` object often isnt fully initialized when your page script runs, even with a setTimeout. The timing depends on when HubSpot’s tracking script loads and initializes the cookie banner functionality. What usually works better is listening for the HubSpot script to be ready before calling the banner method. Something like this approach tends to be more reliable:

var checkHsp = setInterval(function() {
 if (typeof _hsp !== 'undefined' && _hsp.push) {
 _hsp.push(['showBanner']);
 clearInterval(checkHsp);
 }
}, 100);

You might also want to try `_hsp.push([‘revokeCookieConsent’])` first if the user has already consented, as `showBanner` sometimes wont fire if consent was previously given. Theres some documentation on the cookie banner API here (Accounts Dashboard | HubSpot ) (Consent banner API - HubSpot docs )

Another thing to check is whether the page has the cookie banner enabled in page settings. If its disabled for that specific page the API calls wont do anything regardless of timing.

If none of that works, some teams have resorted to triggering a click event on the cookie settings link element directly. Note: The content is based on my personal experience and was refined using AI for better clarity.

Hope this gets your customer unstuck!