惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
Recent Commits to openclaw:main
Recent Commits to openclaw:main
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
罗磊的独立博客
V
Visual Studio Blog
爱范儿
爱范儿
H
Help Net Security
J
Java Code Geeks
I
InfoQ
Recent Announcements
Recent Announcements
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Recorded Future
Recorded Future
Jina AI
Jina AI
Microsoft Security Blog
Microsoft Security Blog
WordPress大学
WordPress大学
GbyAI
GbyAI
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
Scott Helme
Scott Helme
S
SegmentFault 最新的问题
S
Securelist
L
LINUX DO - 热门话题
Cyberwarzone
Cyberwarzone
C
Cisco Blogs
Simon Willison's Weblog
Simon Willison's Weblog
G
Google Developers Blog
酷 壳 – CoolShell
酷 壳 – CoolShell
博客园 - 叶小钗
T
The Blog of Author Tim Ferriss
博客园_首页
B
Blog
F
Fortinet All Blogs
AWS News Blog
AWS News Blog
V
Vulnerabilities – Threatpost
S
Secure Thoughts
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
Forbes - Security
Forbes - Security
S
Security @ Cisco Blogs
T
Threat Research - Cisco Blogs
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
S
Schneier on Security
Project Zero
Project Zero
Martin Fowler
Martin Fowler
C
Cybersecurity and Infrastructure Security Agency CISA
N
Netflix TechBlog - Medium
N
News and Events Feed by Topic

Example blog

Ghost routing explained with routes.yaml examples — routes, collections & taxonomies Ghost redirects explained with practical redirects.yaml examples How to Serve JSON or XML Data in Ghost How to Change Your Default Post Template in Ghost Ghost Custom Theme Settings How to add Google Fonts to Ghost Themes How to Configure Ghost with Mailgun Ghost Theme Structure & Organization How to Make Custom Templates in Ghost Themes How to Install Ghost CMS via Ghost-CLI How to Add Syntax Highlighting to Ghost The best Ghost CMS hosting platforms Ghost 6.0 — Social Web and Native Ghost Analytics Ghost CMS Social web beta, email 2FA and more author social links How to keep custom design settings when updating your Ghost theme How to use the public preview card in Ghost How to add members-specific sections in Ghost How to customize the default content CTA in Ghost How to build a custom homepage in Ghost An overview of Ghost editor cards and and how they work Ghost CMS News: One-time payments & collecting sales tax How to customize the private site access template in Ghost How to add custom fonts in Ghost themes Ghost CMS News: Additional payment methods & internal linking How to use Code Injection in Ghost How to set meta data of your custom routes & collections in Ghost Ghost CMS News: TK reminders, ActivityPub and improvements How to format dates and use the date helper in Ghost Ghost CMS internationalization, custom fonts & spam protection Understanding and optimizing post and page settings in Ghost CMS How to Deploy Your Ghost Theme with GitHub Actions How to create a custom recommendations page for your Ghost CMS theme Ghost CMS News: New editor, refreshed settings & recommendations Ghost CMS News: Source - the new default theme and native image editing How to Add Different Logos for Dark & Light Themes in Ghost Upgrade to Node v18 for Ghost CMS & common errors Ghost Snippets: Adding Schema markup in Ghost How to add a scroll-based progress bar to your Ghost CMS site How to Create a Custom Navigation Template in Ghost How to Segment Subscribers with Member Labels in Ghost The best way to create a contact page in Ghost How to Use the Ghost Subscription Forms in Your Theme & Posts How to update your Ghost site URL when self-hosting Ghost CMS News: Signup cards and better landing pages How to Add Breadcrumbs to Your Ghost Theme How to integrate the Applause Button into your Ghost theme How to Hide a Post From the Home Page in Ghost CMS Ghost CMS block and contentFor helper overview & tips How to add Image Lightbox to Ghost Themes Ghost CMS News: Signup form embed, new editor and bulk actions. Biron Themes becomes Bright Themes 🎉 How to Audit & Test a Ghost Theme How to Create Related Posts Section in Ghost How to Use Ghost Filter Expressions Ghost CMS newsletter settings and post analytics How to Update Your Ghost Theme When We Release New Versions Ghost CMS News: Automatic list cleaning & email troubleshooting How to Create a Featured Post Slider in Ghost How to Add Reading Time to Ghost Blog Posts How to Create a Post Archive for Your Ghost Theme Ghost CMS Price Helper Overview & Tips Self-Hosted Ghost CMS with DigitalOcean Ghost CMS News: Member Growth Sources & Audience Feedback How to Open External Links in a New Tab in Ghost How to Integrate Google Analytics with Ghost Ghost CMS News: History Log & Newsletter Analytics How to Automatically Add Member Labels From Referral Traffic in Ghost? Ghost CMS News: Free trials & email notifications Ghost CMS Match Helper Usage & Tips Ghost CMS News: Native Comments Ghost CMS News: Ghost Explore & Premium Newsletter Previews Ghost Snippets: Custom Progress Cards & Steps Ghost CMS News: Native Search The Best Ghost CMS Search Plugins & Libraries Ghost Snippets: Custom Stylish Tables How to Add a Scroll Top & Progress Indicator Button in Ghost Ghost Snippets: Accordions How to Add Tag Dropdown to Your Ghost Theme Ghost 5.0 released 🎉 Ghost Snippets: Custom Subscribe Forms Ghost Snippets: Custom Alert Boxes How to Show Post or Newsletter Issue Number in Ghost How to Self-Host Google Fonts in Ghost CMS Ghost CMS News: Membership, Tiers & Activity Feed Custom Pages in Ghost CMS Themes Ghost CMS Search Using Fuse.js Ghost CMS News: Offers and Discounts & New Cards Ghost CMS News: Membership tiers, email CTA & filters Ghost CMS News: Grammarly Support & Feature Image Captions. Ghost CMS News: Improved Member Accounts & Personalized Newsletter. Ghost 4.0 Launched With Native Newsletters & Membership Ghost CMS News: Cancellation Feedback & Newsletter Stats. Ghost CMS News: Improved Member Dashboard & Sidebar Views. Ghost CMS News: Google Pay support, email newsletters & secondary navigation Ghost CMS News: Member Support, Portal & Content Snippets. Ghost CMS News: Referral Programs & Responsive Images. Ghost Themes as Progressive Web Apps Ghost 3.0 is here with brand new features Ghost 2.0 is here with new features How to Add Search to Ghost Using ghostHunter
Trigger the Ghost Portal popup based on page scroll progress
Bright Themes · 2024-02-13 · via Example blog

The Ghost Portal became a very powerful and important part of Ghost CMS, it offers a seamless way to capture emails and present your membership to your audience.

This guide will help you understand how you can trigger the Ghost Portal popup based on the user's page scroll progress, but first let's see why this could be helpful.

Depending on your objectives and strategy, popups can be used to:

  1. Improve engagement - strategically placing the popup after a certain scroll depth, you ensure that the user is already interested and engaged in your content. This increases the likelihood of the user responding positively to your call-to-action, whether it's signing up for a newsletter, making a purchase, or subscribing to your membership.

  2. Reduced bounce rates - popups that appear immediately after a webpage loads can often be intrusive and off-putting to users, leading to increased bounce rates. However, by triggering the popup based on the user's scroll progress, you ensure that the user has had the opportunity to interact with your content and understand the value you offer before being presented with a call-to-action. This can significantly reduce bounce rates and improve the overall user experience.

  3. Increased conversion rates - When users are presented with a relevant offer or call-to-action at the right time in their browsing journey, they're more likely to convert. Scroll-triggered popups give you the power to make this happen, turning passive browsers into active customers or subscribers.

You can develop your own custom popup, but a quick and easy way to implement this is using the existing Ghost Portal.

Ghost Portal is a built-in feature of Ghost, which allows you to handle member sign-ups and logins directly on your site. It is designed to provide a smooth experience for both site owners and users. Ghost Portal is highly customizable and integrates well with Ghost's Members & Subscriptions feature.

Ghost Portal can be triggered by links(#/portal), or using data properties (data-portal), but in this guide we will go one step further and trigger it based on the scroll progress.

The first thing we need for this is the scroll event listener:

window.addEventListener("scroll", () => {
  let scrollTop = window.scrollY;
  let docHeight = document.body.offsetHeight;
  let winHeight = window.innerHeight;
  let scrollPercent = scrollTop / (docHeight - winHeight);
  let scrollPercentRounded = Math.round(scrollPercent * 100);
  
  if (scrollPercentRounded > 25) {
    openPopup();
  }
});

In the code above the 'scroll' event listener calculates the percentage of the page that has been scrolled. Once the user scrolls through 25% of the page, the openPopup function is called.

Here's the openPopup function:

function openPopup() {
  const popupLink = document.createElement('a')
  popupLink.setAttribute('href','#/portal')
  popupLink.click();
}

This function will create a link element and assign the #/portal to its href attribute. You can point to different screens from portal like signup, or a specific membership tier. (Check your Settings > Portal for all the available links).

If you add those two function in your Code Injection footer, the Ghost Portal will appear once you scroll past 25% of the page, however you will probably want to add some conditions besides the scroll percentage. You probably want at least to make that the user is not a member, and to not spam the user by triggering the popup too frequently.

To solve this we will implement those checks. First, a function to check if the current user is a member:

async function isMember() {
  const response = await fetch(`${location.origin}/members/api/member/`);
  const bMember = response.status === 200 ? true : false;
  return bMember
}

Next, let's extend the openPopup function with those checks:

async function openPopup() {
  const member = await isMember();
  const timeDelta = (new Date() - new Date(localStorage.getItem('POPUP_OPENED'))) / 1000;
  
  if (!member && timeDelta > 60) {
    localStorage.setItem('POPUP_OPENED', new Date())
    const popupLink = document.createElement('a')
    popupLink.setAttribute('href','#/portal')
    popupLink.click();
  }
}

In the code above, we first determine if the user is already a member. If they are not, we then check the time since the popup was last opened. If it has been over 60 seconds, we trigger the popup.

Warning

Note that the 60 seconds is for demo purposes, you'll probably want to change that.

Here's the complete code, which can be added either in your Site Code Injection or in a specific Post/Page Code Injection:

<script>
async function isMember() {
  const response = await fetch(`${location.origin}/members/api/member/`);
  const bMember = response.status === 200 ? true : false;
  return bMember
}
  
async function openPopup() {
  const member = await isMember();
  const timeDelta = (new Date() - new Date(localStorage.getItem('POPUP_OPENED'))) / 1000;
  
  if (!member && timeDelta > 60) {
    popupOpened = true;
    localStorage.setItem('POPUP_OPENED', new Date())
    const popupLink = document.createElement('a')
    popupLink.setAttribute('href','#/portal')
    popupLink.click();
  }
}
  
window.addEventListener("scroll", () => {
  let scrollTop = window.scrollY;
  let docHeight = document.body.offsetHeight;
  let winHeight = window.innerHeight;
  let scrollPercent = scrollTop / (docHeight - winHeight);
  let scrollPercentRounded = Math.round(scrollPercent * 100);
  
  if (scrollPercentRounded > 25) {
    openPopup();
  }
});
</script>

And here's a link to a working demo on the Saaga: https://saaga.brightthemes.com/new-horizons-probe


With such a strategy, you can subtly encourage your readers to become members, ensuring they've engaged with your content before being presented with the option to subscribe. It's a good example of how Ghost's flexibility allows you to provide a customized, user-friendly experience.