Paywall
A collection of methods to manage your content paywall, track free article views, and determine when to restrict content or display a paywall to the user.
read
Get the current active paywall.
Example
const activePaywall = window.Pelcro.paywall.read();
console.log(activePaywall);
getProduct
Get the product linked with the active paywall.
Example
const paywallProduct = window.Pelcro.paywall.getProduct();
console.log(paywallProduct);
freeVisitsLeft
Get the number of free visits left according to the targeted paywall.
Example
const visitsLeft = window.Pelcro.paywall.freeVisitsLeft();
console.log(visitsLeft);
displayNewsletterPaywall
Returns a boolean that indicates whether the newsletter paywall should be displayed or not.
Example
const shouldDisplayNewsletterPaywall = window.Pelcro.paywall.displayNewsletterPaywall();
console.log(shouldDisplayNewsletterPaywall);
displayMeterPaywall
Returns a boolean that indicates whether the meter paywall (Shows the number of free visits left) should be displayed or not. True when a user still has free visits left.
Example
const shouldDisplayMeterPaywall = window.Pelcro.paywall.displayMeterPaywall();
console.log(shouldDisplayMeterPaywall);
displayPaywall
Returns a boolean that indicates whether the blocking paywall should be displayed or not. True when a user had used all free visits allowed. dispatchPaywallDisplayedEvent default value is true, passing it as false will not. Emits the PelcroPaywallDisplayed
DOM event.
Example
const shouldDisplayPlansPaywall = window.Pelcro.paywall.displayPaywall(false);
console.log(shouldDisplayPlansPaywall);
isArticleRestricted
Returns a boolean that indicates whether the user is authorized to view the current article based on the paywall rules set in the product configuration.
Example
const isArticleRestricted = window.Pelcro.paywall.isArticleRestricted();
console.log(isArticleRestricted);
Updated about 16 hours ago