Make the offer when a reader keeps coming back
A reader has visited four times this week, and most of what they read is climate coverage. A monthly meter either stopped them on the first visit or has not stopped them at all. This is the reader most likely to pay, and right now they are on the site.
visits_7d- Separate visits in the last seven days
top_section_30d- The section they read most in the last 30 days
Shows the subscription offer once a reader reaches three visits in a week, and names the section they keep reading in the headline of the offer.
from datetime import timedelta
from snowplow_signals import (
Attribute, AtomicProperty, EntityProperty, Event, StreamAttributeGroup, domain_userid,
)
page_view = Event(name="page_view", vendor="com.snowplowanalytics.snowplow", version="1-0-0")
visits_7d = Attribute(
name="visits_7d",
type="int32",
events=[page_view],
aggregation="approx_count_distinct",
property=AtomicProperty(name="domain_sessionid"),
period=timedelta(days=7),
)
top_section_30d = Attribute(
name="top_section_30d",
type="string",
events=[page_view],
aggregation="most_frequent",
property=EntityProperty(vendor="com.example", name="article", major_version=1, path="section"),
period=timedelta(days=30),
)
# Published as the paywall_returning service your article page reads.
paywall_returning = StreamAttributeGroup(
name="paywall_returning",
version=1,
attribute_key=domain_userid,
owner="you@example.com",
attributes=[visits_7d, top_section_30d],
)// In the code that renders the article page
const reader = await signals.getServiceAttributes({
name: "paywall_returning",
attribute_key: "domain_userid",
identifier: domainUserId,
});
// { visits_7d: 4, top_section_30d: "climate" }
if (reader.visits_7d >= 3) {
paywall.show({
offer: "standard",
headline: `Keep reading ${reader.top_section_30d} coverage`,
});
}