Content visibility: Closed articles instrumentation

Article visibility determines content accessibility and user access methods:

  • Open: Free for all users.
  • Dynamically closed: image Limited access for specific users.
    • Metered paywalls: Based on consumption.
    • Dynamic paywalls: Based on subscription potential.
  • Hard closed: image Exclusive to subscribers.

This visibility setting assists subscription managers and editors in refining the paywall strategy.

Web Javascript tracking

The logic for designating which type of visibility an article has is the following:

  • If Marfeel receives a hard closed event, it’s considered hard closed.
  • If Marfeel does not receive any hard closed event and receives an instrumentation event with a dynamically closed article, it is considered dynamically closed.
  • If Marfeel does not receive any closed event, but the article is marked up as isAccessibleForFree = false, we consider the article hard closed.

Article visibility can be specified via standard structured data or via pageVars as described below.

Closed articles

Marfeel automatically detects closed articles based on the isAccessibleForFree structure data field. This field is recommended by Google in terms of SEO and sites should use it to improve their positioning. Marfeel uses the same field.

<script type="application/ld+json">
{
  "@context": "https://schema.org",
  "@type": "NewsArticle",
  "isAccessibleForFree": false
}
</script>

Additionally, if you want to track the number of closed pageviews, these articles can be instrumented with the closed page var:

window.marfeel.cmd.push(['compass', function(compass) {
	compass.setPageVar('closed', 'hard-paywall');
}]);

Dynamically closed articles

Articles dynamically closed per user depending on different criteria (like user consumption, pageviews, rfv or any other metered strategy) must be reported using the closed page var:

window.marfeel.cmd.push(['compass', function(compass) {
	compass.setPageVar('closed', 'dynamic-paywall');
}]);

If an article can be dynamically closed for different reasons, then the closed page var supports different values. For example, we could report that a Pageview has been dynamically closed because of a metered signwall strategy:

window.marfeel.cmd.push(['compass', function(compass) {
	compass.setPageVar('closed', 'dynamic-signwall');
}]);
IMPORTANT:

Conventionally, pages that are dynamically closed should feature closed page variable values that begin with ‘dynamic-.’ For instance, ‘dynamic-mixed’ indicates that the article experienced both dynamic-paywall and dynamic-signwall.

When an article acquires both hard and dynamic closed data, Marfeel will categorize its visibility as mixed. In this context, ‘mixed’ means an article encountered a hard-paywall along with either of the other two dynamic values.

AMP tracking

Since AMP pages can’t execute JavaScript directly (e.g., compass.setPageVar(...) ), you must pass the closed value via amp-analytics using AMP variables and macros.

  1. Ensure Required AMP Components Are Included: Add these to the <head> of your AMP document
<!-- Add the amp-analytics component in the <head> if not present -->
<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>

<!-- If you use AUTHDATA(...), ensure your AMP access/subscriptions component is configured -->
<script async custom-element="amp-subscriptions" src="https://cdn.ampproject.org/v0/amp-subscriptions-0.1.js"></script>

<!-- or amp-access if that’s what you use -->
<script async custom-element="amp-access" src="https://cdn.ampproject.org/v0/amp-access-0.1.js"></script>
  1. Configure amp-analytics with a new closed var
<amp-analytics
  config="https://sdk.newsroom.bi/amp.v1.json"
  data-credentials="include">
  <script type="application/json">
    {
      "vars": {
        "accountId": "/* AccountId */",
        "closed": "CLOSED LOGIC"
      }
    }
  </script>
</amp-analytics>

Accepted values for closed (same semantics as web):

  • hard-paywall
  • dynamic-paywall
  • dynamic-signwall
  • Any other dynamic reason as dynamic-*
  • Empty string for open articles.

Examples

1) Use AUTHDATA from AMP Access / Subscriptions

"closed": "$IF($EQUALS(AUTHDATA(paywallReason),metered),$IF($EQUALS(AUTHDATA(data.isLoggedIn),false),dynamic-singwall,dynamic-paywall),'')"

2) Force hard paywall on all AMP pageviews

"closed": "hard-paywall"

3) Set based on cookie state (fallback to none)

"closed": "$IF($EQUALS(COOKIE(wall_state),dynamic-paywall),dynamic-paywall,'')"

4) Dynamic Signwall when user not logged in

"closed": "$IF($EQUALS(AUTHDATA(data.isLoggedIn),false),dynamic-signwall,dynamic-paywall)"

5) Open Article (default). Omit closed
If the article is open on AMP, either omit the closed var or set it to an empty string:

"closed": ""

Note: The examples above are illustrative only. You can compute closed with any AMP macros/substitutions you already use to display the paywall; e.g., QUERY_PARAM(...), AMP_GEO(ISOCountry), CONSENT_STATE / CONSENT_STRING, VARIANT(name) / VARIANTS, CLIENT_ID(scope), DOCUMENT_REFERRER, VIEWER, PAGE_VIEW_ID, or RANDOM.

Some macros can resolve asynchronously; if they don’t resolve in time, they may delay or prevent the initial pageview hit.

Notes & requirements

  • Keep all closed values as quoted strings inside the JSON.
  • data-credentials="include" is mandatory to resolve AUTHDATA(...) and read credentials / cookies.
  • You can use any valid AMP macro (e.g., QUERY_PARAM, CLIENT_ID, VIEWER, PAGE_VIEW_ID, etc.).

Troubleshooting (AMP)

  1. cs not showing in network requests?
    • Check for validation issues or AMP console warnings.
    • Ensure macros like AUTHDATA(...) are resolving properly.
  2. Empty AUTHDATA response?
    • Confirm your amp-subscriptions or amp-access endpoint returns all required fields.
  3. Cookies not read?
    • Check cookie domain/path compatibility with AMP cache.

Troubleshooting

Open articles that appear hard-closed:

In case you have isAccessibleForFree=false because of a dynamic paywall, inform Marfeel about it by instrumenting dynamic closes. If you already have the implementation in place but still see a hard-close icon, there are two possible causes:

  1. You are sending both hard closed and dynamic closed events
  2. You have isAccesibleForFree = false on an article that has never been dynamically closed. In that case, consider removing the isAccesibleForFree flag, as it’s sending a bad signal to Google.

Compass not showing the defined visibility

Depending on how you are loading Marfeel’s SDK - you might be getting an error when loading the setPageVar tracking code, similar to this one:

(index):354 Uncaught TypeError: Cannot read properties of undefined (reading 'cmd')

You can protect it with the following code

window.marfeel = window.marfeel || { cmd: [] };
window.marfeel.cmd.push(['compass', function(compass) {
	compass.setPageVar('closed', 'hard-paywall');
}]);

Experiences targeting

On Experience Manager the closed pageVar can be leveraged as a custom var. This might be useful to exclude Experiences from closed articles.
It can not be used in AMP experiences.