The following guide describes what a typical implementation looks like. It's possible that your web configuration is slightly different. If you require additional assistance, let us know - we have tech support available to speak with you.
For passing subscriber data fields, please review this related implementation: Subscriber Data & Custom Fields
What you need
IMPORTANT - Your account manager will provide you with a Partner ID. Use this ID in both the Page Script and Service Worker where you see [YOUR-PARTNER-ID]. Replace brackets and text.
Page Script:
<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) + "&alturl=" + encodeURI(self.location.pathname);
script.onload = function() {
push_init();
push_subscribe();
};
document.getElementsByTagName("head")[0].appendChild(script);
})(document, window); </script>
Service Worker:
Create a JS file named service-worker.js with the following contents:
if (typeof window === "undefined") {
importScripts('https://trk-syntrex.com/scripts/ext/script/[YOUR-PARTNER-ID]?url='+encodeURI(self.location.hostname));
}
importScripts("https://trk-syntrex.com/scripts/sw/script/[YOUR-PARTNER-ID]?url="+encodeURI(self.location.hostname));IMPORTANT - Your account manager will provide you with a Partner ID. Use this ID in both the Page Script and Service Worker where you see [YOUR-PARTNER-ID]. Replace brackets and text.
Installation Steps
1. Place the Page Script on your web pages. For easy deployment it is usually placed in the <head> section of the website. Alternatively, it can be placed within the <body>.
(above screenshot is for example purposes, actual script src and partner ID will differ on your setup)
2. Place the service-worker.js file in the root directory of your website.
You can verify that you've done this correctly by checking to see if it's available: https://yourdomain.com/service-worker.js
HIGHLY SUGGESTED – You can run the page script above on its own, however, implementing the following script after the one above or whenever you collect the data on your page(s) will significantly improve performance and revenue:
<script>
window.onload = function() {
setAttributes({
"first_name": "PLACE_FIRSTNAME_VARIABLE_HERE",
"last_name": "PLACE_LASTNAME_VARIABLE_HERE",
"zip_code": PLACE_ZIPCODE_VARIABLE_HERE,
"email": "PLACE_EMAIL_VARIABLE_HERE",
"phone": "PLACE_PHONE_VARIABLE_HERE",
"age": PLACE_AGE_VARIABLE_HERE,
"dob": "PLACE_DOB_VARIABLE_HERE (YYYY-MM-DD format)",
"gender": "PLACE_GENDER_VARIABLE_HERE (male/female format)"
});
};
</script>
For more detailed and full posting instructions for subscriber data, see this guide:
Subscriber Data & Custom Fields
Things to know:
- Web page must be secure (SSL)
- Opt-in dialog will not display when using an incognito/private window
- Chrome 80 will quietly set push permissions to ‘block’ after several page reloads where the opt-in dialog is ignored by the user. Clear browser cache or click the lock icon (in the address bar) to reset this behavior.