How it works
Custom Fields and Subscriber Data are used for tracking, segmentation, and message personalization. Personally identifiable information (PII), such as first name and last name, can help us tailor creatives and pre-populate forms - leading to stronger monetization.
To attach these attributes to the Push Subscription record you can use any of the following methods:
Query String - When the opt-in occurs, any standardized keys present in the query string will be attached to the Push Subscription.
Push JavaScript - Prior to opting in, attributes can be added to the Push JavaScript so that when the user does opt in, these attributes are attached to the Push Subscription.
JavaScript Function - Post-subscription, you can invoke a JavaScript function at any time to add attributes to the Push Subscription.
Definitions for Key and Values
| Key | Purpose | Example |
| utm_source | Typically identifies a traffic source | |
| utm_medium | Typically identifies how the user got to page | Banner_19 |
| utm_campaign | Typically Identifies a specific promotion or strategy | adgroup25-retargeting-list |
| source_one | Custom Field. Use for anything. | customdata |
| source_two | Custom Field. Use for anything. | customdata |
| source_three | Custom Field. Use for anything. | customdata |
| source_four | Custom Field. Use for anything. | customdata |
| source_five | Custom Field. Use for anything. | customdata |
| first_name | User's first name | John |
| last_name | User's last name | Smith |
| User's email | johnsmith@yahoo.com | |
| zip_code | User's zip code | 90210 |
| age | User's age | 48 |
| dob | User's date of birth | 1980-06-08 |
| address | User's address | 123 main st. |
| address2 | User's address 2 | apt 2 |
| city | User's city | Las Vegas |
| state | User's 2-char state abbrev. | NV |
| phone | User's phone number | 1231231234 |
| gender | User's gender (male or female) | male |
Example & Implementation
Option #1 - Query String (Subscription Time)
Let's say you collect push subscriptions on the following page:
https://your-domain.com/landing-page/1To attach attributes to the push subscription, simply add the desired keys and values to a query string:
https://your-domain.com/landing-page/1/?utm_source=Google&utm_medium=cpc
Option #2 - Push JavaScript (Before Subscription Time)
The standard page script, which calls our push functions, should already be on your pages. It looks like this:
<script> (function(document, window) {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://trk-syntrex.com/scripts/push/script/[YOUR-PARTNER-ID]?url=" + encodeURI(self.location.hostname);
script.onload = function() {
push_init();
push_subscribe();
};
document.getElementsByTagName("head")[0].appendChild(script);
})(document, window); </script>
You will be adding the following:
var utmObj = {
"utm_source": '',
"utm_medium": '',
"utm_campaign": '',
"source_one": '',
"source_two": '',
"source_three": '',
"source_four": '',
"source_five": ''
}
setUtm(utmObj);
The result should look like this:
<script> (function(document, window) {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://trk-syntrex.com/scripts/push/script/[YOUR-PARTNER-ID]?url=" + encodeURI(self.location.hostname);
script.onload = function() {
push_init();
var utmObj = {
"utm_source": '',
"utm_medium": '',
"utm_campaign": '',
"source_one": '',
"source_two": '',
"source_three": '',
"source_four": '',
"source_five": ''
}
setUtm(utmObj);
push_subscribe();
};
document.getElementsByTagName("head")[0].appendChild(script);
})(document, window); </script>
You will populate values in the desired attributes:
<script> (function(document, window) {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://trk-syntrex.com/scripts/push/script/[YOUR-PARTNER-ID]?url=" + encodeURI(self.location.hostname);
script.onload = function() {
push_init();
var utmObj = {
"utm_source": 'Google',
"utm_medium": 'cpc',
"utm_campaign": 'spring_sale',
"email": 'johnsmith@yahoo.com',
"source_one": 'df27se29a85tehrvhbm6t658'
}
setUtm(utmObj);
push_subscribe();
};
document.getElementsByTagName("head")[0].appendChild(script);
})(document, window); </script>
*Note that if you are setting the segmentation fields via the JavaScript method the query string will be ignored.
Option #3 - JavaScript function (After Subscription)
You may add a custom attribute to the current subscriber at any point by calling the setAttributes JavaScript function.
- This function can be useful for dynamically assigning attributes to JavaScript objects based on certain conditions or requirements.
- Ensure that the attributes parameter is an object with valid attribute names and values.
- Modify the function implementation according to your specific use case, such as storing attributes in variables.
Below is an example:
setAttributes({"email":"johnsmith@yahoo.com", "age":48, "gender":"male", "first_name":"john", "last_name":"john", "zip_code":"90210"});
Please note that the 'setAttributes' function is defined within the push page script. Make sure that the script is loaded on the page before calling the 'setAttributes' function. Below is an example:
<script> (function(document, window) {
var script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://trk-syntrex.com/scripts/push/script/[YOUR-PARTNER-ID]?url=" + encodeURI(self.location.hostname);
script.onload = function() {
push_init();
push_subscribe();
};
document.getElementsByTagName("head")[0].appendChild(script);
})(document, window); </script>
<script>
window.onload = function() {
setAttributes({
"first_name": "John",
"last_name": "Smith",
"zip_code": 90210,
"email": "johnsmith@yahoo.com",
"age": 48,
"gender": "male"
});
};
</script>