Lesson notes
How it works
How a metered paywall works
A metered paywall lets people read a set number of articles each month for free. Once they reach the limit, the next new article is blocked and a paywall asks them to log in or subscribe. MemberScript 228 does this on a Webflow blog. By default the limit is three articles and the count resets at the start of each calendar month.
The script keeps a list of article IDs the reader has opened this month. Opening an article that's already on the list doesn't count again, so readers can go back to articles they've already read. For visitors who aren't logged in, the list lives in the browser's local storage. For members, it's saved in their member JSON under article_meter, with the period, the article IDs and the count. If a visitor logs in partway through the month, the articles they read logged out are merged into their member JSON.
Setting limits for visitors and for each plan
Add the script to your blog post template page rather than site-wide, so it only runs on articles. Then put the attributes on the wrapper around your rich text element.
ms-paywall-limit sets the monthly limit for visitors who aren't logged in. ms-paywall-plan-limits sets limits for members by plan ID, written as pairs like pln_basic:3,pln_premium:6,pln_teams:unlimited. If a member has more than one matching plan, they get the most generous limit. If you don't set plan limits, members with an active paid plan skip the paywall entirely.
- Add MemberScript 228 to your blog post template page.
- Add a field to your blog collection, paste each item's CMS ID into it, and bind it to
ms-paywall-article-idon the article wrapper. - Add
data-ms-paywall="article"andms-paywall-limit="3"to the same wrapper. - Add
ms-paywall-plan-limitswith your own plan IDs and limits. - Add
ms-paywall-strip-content="true",ms-paywall-tamper-proof="true",ms-paywall-hide="false"andms-paywall-blur="false".
Building the paywall itself
Give the paywall's outer div data-ms-paywall="wrapper" and set it to display none. The script shows it when the limit is reached. Inside it, the script fills in any element with data-ms-paywall="read" (articles read), data-ms-paywall="limit" and data-ms-paywall="reset-date". Add a subscribe button, either linked to your pricing page or with data-ms-price:add="PRICE_ID", and a login button linked to your login page.
With strip content on, the script empties the article from the page instead of blurring it. ms-paywall-teaser-selector=".paywall-teaser" keeps any element with that class as a preview. Tamper proof puts the paywall back if someone deletes it in the browser's developer tools. These run after the page loads, so the article is still in the page source, and clearing local storage resets a logged-out visitor's count. Keep gated content or hosted content for anything you sell.