Sailthru.track (for Legacy Horizon JS)

NOTE: These instructions should only be used with the V1 Horizon JavaScript. If using the current JavaScript, see Personalization Engine Setup. If you have any questions on what version you have implemented, please reach out to your Customer Success Manager or the Support team. If your website does not load new pages for individual products and content (e.g. sites that are heavily AJAX-reliant), or if you have multiple URLs for the same content item (e.g. a slideshow with different URLs for each slide), Sailthru.track() can be an extremely useful alternative to the standard implementation. Before we walk you through the JavaScript examples, here are the parameters available in Sailthru.track():
  • domain: Your Horizon domain. Usually matches your Horizon CNAME.
  • spider: Default is true. False prevents pageviews or content creation in Sailthru. User interests are still collected.
  • noPageview: Content won’t be spidered, user interests will not be collected.
  • track_url: Default is true. False prevents the .track call or basic setup call from firing.
  • url: Manually set the url to be sent into Sailthru. Blank uses url of the page.
  • tags: Manually set the interest tags to be added to a profile. Missing param uses the tags specified on the page via the documented meta tags.
  • use_stored_tags: Don’t use the tags on the page to add to the interest profile, instead use the tags already stored in Sailthru’s Content Library for the URL being tracked.
Sailthru.track() allows you to specify a URL to overwrite the URL of the actual webpage the user is on. The standard implementation of Sailthru.track() involves dropping this on your webpage: Sailthru.track() Function Example: Redirecting a Pageview to a Different URL, Adding Additional Tags
<script type="text/javascript" src="http://ak.sail-horizon.com/horizon/v1.js"></script>
<!-- if loading for secure domain, use: https://ak.sail-horizon.com/horizon/v1.js -->
<script type="text/javascript">
 $(function() {
    if (window.Sailthru) {
        Sailthru.track({
            domain: 'horizon.sailthru.com',
            spider: true,
            track_url: true,
            url: "http://www.example.com/DEF",
            tags: ["any","additional","tags"],
        });
    }
 });
 </script>
In the above example, if the code was dropped on http://www.example.com/ABC, then it would instead attribute a pageview to www.example.com/DEF. All the previously-spidered tags from /DEF, plus any additional tags specified above, would get posted to the user’s profile. Sailthru.track() can also be used to turn onsite actions that can be handled by Javascript (like a button click) into events that will add interest data and even record additional pageviews on a user. For example, this code turns Sailthru.track() into a function called trackButton() that fires whenever the “Fire Track!” button is pressed: Sailthru.track() Function Example: Triggering from an Onsite Event, Posting a Pageview and Additional Tags to a User
<script type="text/javascript">
   function trackButton(){
         Sailthru.track({
            domain: 'horizon.sailthru.com',
            spider: true,
            track_url: true,
            url: "http://www.example.com/DEF",
            tags: ["tags","from","track"],
         });
      }
   });
</script>

<button type="button" onclick="trackButton()">Fire Track!</button>

 

When the button is clicked, the trackButton function is executed, and Sailthru.track fires a pageview for http://www.example.com/DEF with the options provided to it.

Contact us

Top