Permission: Campaign entities
The Preferences message JavaScript code is a snippet that is added to a web property and allows an end-user to resurface a Preferences message. Using this link/button, end-users can directly manage their marketing and legal preference selections on an ongoing basis.
- Configure resurface Preferences message Javascript code
- Implement resurface Preferences message Javascript code
Configure resurface Preferences message Javascript code
The code snippet to resurface your 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 Preferences message ID to the loadPreferenceCenter
function.
Retrieve the Preferences message ID by clicking Messages on the left-hand panel and selecting Preferences.
Use the property field in the upper right-hand corner to select a property for which you will resurface a Preferences message.
Navigate to your Preference message in the list and copy the ID inline with the Preferences message name.
Format the resurface 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 use-cases where an end-user's email is required, your organization will need to pass the following to the loadPreferenceCenter
function:
- Preferences message ID
- End-user email address
Retrieve the Preferences message ID by clicking Messages on the left-hand panel and selecting Preferences.
Use the property field in the upper right-hand corner to select a property for which you will resurface a Preferences message.
Navigate to your Preference message in the list and copy the ID inline with the Preferences message name.
In addition to the Preference 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 Preferences message Javascript code
Attach the 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