Skip to content

Navigation tracking

The Ownpage technology captures and models your readers' navigation habits to produce personalized newsletters. Based on navigation data, our algorithms generate individual selections of contents for every known contact.

Please integrate navigation tracking as described below to enable personalization.

With the Ownpage JS library

The easiest method is to use the Ownpage JS library :

1
2
3
4
5
6
7
8
9
<script type="text/javascript">
(function(){
    function loadOwnpageScript(e){var t="https://script.ownpage.fr/v1/",a=document.createElement("script"),n=document.getElementsByTagName("script")[0];a.type="text/javascript",a.defer=1,a.async=1,a.src=t+"ownpage.js",a.onload=e,a.readyState?a.onreadystatechange=function(){("loaded"==a.readyState||"complete"==a.readyState)&&(a.onreadystatechange=null,e&&"function"==typeof e&&e())}:a.onload=function(){e&&"function"==typeof e&&e()},n.parentNode.insertBefore(a,n)}

    loadOwnpageScript(function () {
       Ownpage.trackPage(CLIENT_TRACKING_KEY, USER_EMAIL_MD5);
    });
})();
</script>

Insert this code on the pages-articles by replacing :

  • CLIENT_TRACKING_KEY : A String. Your tracking key given by Ownpage, example "abcdef".
  • USER_EMAIL_MD5 : A String. The hash of the current email address using MD5 algorithm. This parameter must be empty for anonymous users (null). In javascript, you can transform a string into his md5-hash easily with an open-source library.
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
<script type = "text/javascript" src = "https://cdnjs.cloudflare.com/ajax/libs/blueimp-md5/2.10.0/js/md5.min.js" ></script>
<script type="text/javascript">
(function(){
    function loadOwnpageScript(e){var t="https://script.ownpage.fr/v1/",a=document.createElement("script"),n=document.getElementsByTagName("script")[0];a.type="text/javascript",a.defer=1,a.async=1,a.src=t+"ownpage.js",a.onload=e,a.readyState?a.onreadystatechange=function(){("loaded"==a.readyState||"complete"==a.readyState)&&(a.onreadystatechange=null,e&&"function"==typeof e&&e())}:a.onload=function(){e&&"function"==typeof e&&e()},n.parentNode.insertBefore(a,n)}

    loadOwnpageScript(function () {
       Ownpage.trackPage("my_tracking_key", md5("user_email@domain.com"));
    });
})();
</script>

Note: hashing with MD5 algorithm is a way for us to have a unique identifier. This is in no way used as a security system. Our hashing algorithms are much more powerful.

This tracking code does the following :

  • The anonymous (function(){ })(); is used to launch the execution of its content, only when the page is fully loaded.
  • Then the function loadOwnpageScript is defined and executed. It loads in an asynchronous way the Ownpage library.
  • The trackPage method is called when the Ownpage object is available. The method calls our API to notify the event.

Without the Ownpage JS library

The Ownpage API can be directly called :

1
POST https://api.ownpage.fr/v1/collect/hits

The request body describes the navigation action :

1
2
3
4
5
6
{
    "tracking_key" : "abcdef",
    "url" : "http://www.canardmag.fr/article-123.html",
    "user" : "123456",
    "cookie" : "abcdefghijk"
}

With :

  • tracking_key : your tracking key given by Ownpage (example "abcdef"). You can find it on the dashboard.
  • url : URL of the current page the user is reading.
  • user : the current user email, hashed in MD5. This identifier should be void for anonymous users (null).
  • cookie : the ownpage_fp2 cookie value. You will need to create this cookie for each user (including unknown users), and give it a unique value. We recommend to use a UUID.

Example of implementation:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
require 'rest-client'
require 'json'
require 'digest'
require 'securerandom'

TRACKING_KEY = "your_tracking_key"

OWNPAGE_API_ENDPOINT = "https://services.ownpage.fr/v1/collect/hits"
current_url = getCurrentURL()

# Check if the user is connected or not
user_value = is_user_connected? ? Digest::MD5.hexdigest(user.email) : nil

# Give the user a cookie if he doesn't have it, with a uuid as a value
cookies[:ownpage_fp2] = SecureRandom.uuid unless cookies[:ownpage_fp2]

# Send the request to Ownpage
RestClient::Request.execute(
        method: :post, 
        url: "#{OWNPAGE_API_ENDPOINT}",
        payload: {
          "tracking_key": TRACKING_KEY,
          "url": current_url,
          "user": user_value,
          "cookie": cookies[:ownpage_fp2]
        }.to_json
    )

Remarks concerning cookies and mobile applications :

Cookies are not available in native mobile applications. You should replace the value of the cookie field with the following ids :

Check the tracking

To check the tracking, please use our Chrome extension.

Missing Ownpage tracking

Tracking absent

Tracking ok

Tracking en place

What's next?

Once the tracking is working as intended, you need to tell us it's in production, so we can activate the collect on our side. Then, you will be able to see the content we gather from your website, as well as the traffic and all kind of metrics. It's now time to create your template and send your first personalized newsletter!

Comments