Prerequisites
Function
This utility allows the browser to update a subscriber as they navigate your webpage. This code is included in the script installed via step 1 of the install process.
Method
Pushnami.update([extras={}])
Arguments
[extras={}](Object)
: Optional object containing subscriber variables to assignBehavior
The update
method will assign query string parameters to subscriber variables along with any values provided in the extras
object. This method will override existing variables of the same name as specified in the URL or extras object. Otherwise, this method will not remove or replace subscriber variables.
Examples
<script type="text/javascript">
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://api.pushnami.com/scripts/v1/push/<API_KEY>";
script.onload = function(){
Pushnami.update(); // Update via params
};
document.getElementsByTagName("head")[0].appendChild(script);
</script>
Updating Pushnami with query string parameters based on an external event (ex: button click) The subscriber test is updated with query string parameters.
<script type="text/javascript">
document.getElementById("btnUpdate").onclick = function(){
Pushnami.update(); // Update via click
}
</script>
Updating Pushnami with “extras
” based on an external event (ex: button click)
The subscriber test is updated as a random number.
<script type="text/javascript">
document.getElementById("btnUpdate").onclick = function(){
Pushnami.update({
test: Math.floor(Math.random()*100).toString()
}); // Update via click
}
</script>