Page tree
Skip to end of metadata
Go to start of metadata

GCN.onecount.track(url, title, referrer, resourceId, callback):

By default, ONEcount widgets track impressions on each page load. For sites where one article is displayed per page, this works fine. But in cases where articles are displayed on the same page, i.e. infinite scroll, only the first one is tracked.

This function is designed to provide an impression track for each article on a page. The function expects three parameters:

  • url: The url of the article that is supposed to be tracked. This is required.
  • title: This should be the same as the title tag if the article was displayed alone on the page.
  • referrer: The referrer of article. (For infinite scroll this can be the previous article in the scroll.)
  • resourceId: this is optional. If set to a valid resourceId, that resource that will be used in order to perform gating or increase view_count. You can pass 0 in order to use the default resource associated with the url if any

  • callback: function to be called after a request has been sent to ONEcount. This can return the number of articles read by the user for products with limit in timeframe

While the impressions are being tracked, ONEcount will also check whether the user's subscription is still valid or not (e.g. limit of X articles per month has been reached). If the subscription is not valid, then the user will be taken to the subscription page.

Let's assume I have a page where the first article is displayed when the page loads and three mores articles are displayed as the user scrolls down. The first article will be tracked by ONEcount, but for the three other articles, a call to GCN.onecount.track needs to be made to tell ONEcount that the articles have been displayed. The url should be the direct url of the article. The referrer should be the previous article's url.

GCN.onecount.gate(resourceId, callback):

Gating is currently done based on a REGEX match of a url segment on page load. This function is designed to allow customers to gate content where gating can not be sufficiently managed using URL segments, or where content must be gated without a page load.

This function expects two parameter :

  1. resourceId : this is the resourceId that will be used for gating and it's required.
  2. callback: this is a function that can be passed. The response from the gating request will be made available in the callback. The callback should expect one parameter which is a JSON object. The JSON object has a property called hasAccess which is a boolean (true/false). true means the user has access and false means he does not.

Resource Ids are available in ONEcount on the resource listing page.

To create a resource that uses this function, choose “Function” from the resource type pull-down, then enter a text return value in the box below. This return value is ignored for now, but may be used to trigger gating in the future.

When the function is called and the user is not subscribed to the product that the resource belongs to, he will be taken to the registration page in order to do so. If he is already subscribed to the product then nothing will happen.