--- title: "Cookie management in the _st module" slug: "cookie-management-in-the-st-module" description: "Manage cookie consent preferences effortlessly with the _st.cookiepermission module and _stCookiePopup for optimal user experience and compliance." updated: 2026-07-13T06:10:34Z published: 2026-07-13T06:10:34Z canonical: "docs.supermetrics.com/cookie-management-in-the-st-module" --- > ## Documentation Index > Fetch the complete documentation index at: https://docs.supermetrics.com/llms.txt > Use this file to discover all available pages before exploring further. # Cookie management in the _st module The `_st.cookiepermission` module lets you read and write cookie consent preferences for the current user. If you are using the native Data Activation cookie consent solution, the `_stCookiePopup` proxy object gives you control over when and how the cookie consent popup is shown. ## _st.cookiepermission methods ### Methods overview | Method | Description | | --- | --- | | `_st.cookiepermission.getCookiePreferences()` | Gets the current cookie preferences for the user. | | `_st.cookiepermission.setCookiePreferences(preferences)` | Sets the cookie preferences for the user. | | `_st.cookiepermission.syncCookiePreferences(preferences)` | Requests a sync of cookie preferences for cross-domain permission sharing. | | `_st.cookiepermission.getPopupViewCount()` | Gets the number of times the cookie popup has been shown to the user. | | `_st.cookiepermission.setPopupViewCount(count)` | Sets the popup view count for the user. | ### Method details #### _st.cookiepermission.getCookiePreferences() Gets the current cookie consent preferences for the user. **Returns:** The cookie preferences object for the user. #### _st.cookiepermission.setCookiePreferences(preferences) Sets the cookie consent preferences for the user. **Parameters:** - **preferences** (object): The preferences object. Keys are consent group identifiers (these match your configuration in the UI, often integers like `1`, `2`, `3`) and values are booleans indicating consent. **Example:** ```javascript var preferences = {}; preferences[1] = true;  // e.g., Strictly Necessary preferences[2] = true;  // e.g., Analytics preferences[3] = false; // e.g., Marketing _st.cookiepermission.setCookiePreferences(preferences); ``` #### _st.cookiepermission.syncCookiePreferences(preferences) Requests a sync of the cookie preferences. Use this to share consent permissions across domains configured within your Data Activation setup. **Parameters:** - **preferences** (object): The preferences object to sync. This uses the exact same format as `setCookiePreferences`, for example `{1: true, 2: true, 3: false}`. #### _st.cookiepermission.getPopupViewCount() Gets the number of times the cookie consent popup has been shown to the user. **Note:** For this value to be greater than 0, the popup implementation configured in the UI must be set to track and increment views. #### _st.cookiepermission.setPopupViewCount(count) Sets the cookie popup view count for the user. **Parameters:** - **count** (integer): The number of times the popup has been viewed. ## _stCookiePopup proxy object > [!NOTE] > Note > > This object is only available if you are using the native Data Activation cookie consent solution. If you are using a third-party Consent Management Platform (CMP), this object will not be present. When the native cookie consent solution is active on a page, a proxy object called `_stCookiePopup` is created automatically. Use its methods to control popup display behavior via custom scripts. ### Methods #### _stCookiePopup.showIfNotSet() Shows the cookie consent popup to the user, but only if they haven't already set their preferences. Once the user gives consent, the popup won't show again. **Example:** ```javascript _stCookiePopup.showIfNotSet(); ``` #### _stCookiePopup.showPopup() Forces the cookie consent popup to show, regardless of whether the user has already set preferences. If the user selects a consent group, the new selection overrides the previous settings. **Example:** ```javascript _stCookiePopup.showPopup(); ``` #### _stCookiePopup.showSettings() Forces the consent settings screen to show directly, without showing the initial popup. If the user selects a consent group, the new selection overrides the previous settings. **Example:** ```javascript _stCookiePopup.showSettings(); ```