Permission: Campaign entities
The Universal Consent and Preferences message JavaScript code is a snippet that is added to a web property and allows an end-user to resurface a Universal Consent and Preferences message. Using this link/button, end-users can directly manage their Marketing Preferences and Legal Transaction selections on an ongoing basis.
- Configure resurface Universal Consent and Preferences message Javascript code
- Implement resurface Universal Consent and Preferences message Javascript code
Configure resurface Universal Consent and Preferences message Javascript code
The code snippet to resurface your Universal Consent and Preferences message uses a loadPreferenceCenter
function to pass the required arguments. The arguments required depends on whether your organization's use case supports anonymous end-users or requires an email address for marketing purposes. Please see the tabs below for more information:
For user-cases that support anonymous end-users, your organization will need to pass the Universal Consent and Preferences message ID to the loadPreferenceCenter
function.
Retrieve the Universal Consent and Preferences message ID by clicking Messages on the left-hand panel and selecting Universal Consent and Preferences.
Use the property field in the upper right-hand corner to select a property for which you will resurface a Universal Consent and Preferences message.
Navigate to your Preference Center message in the list and copy the ID inline with the Universal Consent and Preferences message name.
Format the resurface Universal Consent and Preferences message Javascript code so it adheres to the following:
window._sp_.preferences.loadPreferenceCenter(PREF_MSG_ID)
Note: Ensure your organization includes the id
property, which is the end-user's email address, within the preference_mgmt
object of your client configuration script as well.
For user-cases where an end-user's email is required, your organization will need to pass the following to the loadPreferenceCenter
function:
- Universal Consent and Preferences message ID
- End-user email address
Retrieve the Universal Consent and Preferences message ID by clicking Messages on the left-hand panel and selecting Universal Consent and Preferences.
Use the property field in the upper right-hand corner to select a property for which you will resurface a Universal Consent and Preferences message.
Navigate to your Preference Center message in the list and copy the ID inline with the Universal Consent and Preferences message name.
In addition to the Preference Center message ID, your organization will need a way to pass your end-user's email address to the function. Format the resurface Preferences message Javascript code so it adheres to the following:
window._sp_.preferences.loadPreferenceCenter(PREF_MSG_ID, 'USER_EMAIL')
Implement resurface Universal Consent and Preferences message Javascript code
Attach the Universal Consent and Preferences message JavaScript code to an event handler on your property. Most organizations who implement the JavaScript code on their page will attach the function to the onclick
event of a page element.
//anonymous
<button onclick="window._sp_.preferences.loadPreferenceCenter(28458)">Anonymous User</button>
//email required
<button onclick="window._sp_.preferences.loadPreferenceCenter(28458, 'test@email.com')">UCP</button>
Comments
0 comments