Home > Knowledge Base > Push-notifications > How to pass additional variables for segmentation and personalization of web push notifications? 

How to pass additional variables for segmentation and personalization of web push notifications? 

In order to pass additional variables like subscribers' names or emails, after adding web push integration code to your website (the code generated in your account), you need to add the following code:

 

<script type="text/javascript">
window.addEventListener('load', function() {
    oSpP.push("Name","Name_of_website_user");
    oSpP.push("Email","Email_of_website_user");
});
</script>

 

If the user subscribed to web push first as an anonymous user and a variable became available later the information will be transmitted to the server after the user visits the website again. Thereby the data about the user will be updated after they visit the website next time.

Another Method

Another method to upload additional variables to your SendPulse account is to add to your website additional input fields  with sp_push_custom_data class.

<input class="sp_push_custom_data" type="hidden" name="Variable 1" value="Some data1"> 
<input class="sp_push_custom_data" type="hidden" name="Variable 2" value="Some data2">

Where,
Variable 1 and Variable 2 are an appropriate variables for personal data about a subscriber. For example: “Name”, “Last name”, “Email”.
 
The quantity of lines of code is equal to quantity of variables you need to upload to subscribers’ entry in the web push service in order to personalize and segment your web push notifications.

Both methods described above are applicable for all sites on any CMS.