Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable "Unsubscribe" functionality #99

Open
nring opened this issue Sep 1, 2023 · 1 comment
Open

Enable "Unsubscribe" functionality #99

nring opened this issue Sep 1, 2023 · 1 comment

Comments

@nring
Copy link
Contributor

nring commented Sep 1, 2023

The template we forked our code from implemented a custom Newsletter Subscription button. This hooked into Ghost's membership functionality to opt-in users to newsletters of new blog posts. Ghost's membership functionality is a suite of tools to manage subscriptions and user settings. This poses a number of issues given our current set up.

  1. We're using the hosted version of the Ghost Admin, where we're able to create and edit individual posts. We could host the platform ourselves but that brings with it added overhead and administration. Because we're using the hosted version, a public-facing version of the site is automatically generated with the default Ghost template. We have opted to make this version of the site private (essentially turn it off) so we don't have duplicate content.

  2. The problem with this implementation is that we lose the ability to access membership functionality. This includes newsletter subscriptions as well as a host of other features we're not using at the moment.

  3. We also lose the ability to change what the linked domains are in our auto-generated email newsletters. We have redirects set up to make sure linked content is available on our custom domain (see section on "Other things to keep in mind"). However, the "unsubscribe" link functionality does not work. Currently, it directs to: https://dept-engineering-blog.ghost.io/unsubscribe/?uuid=member-uuid&newsletter=newsletter-uuid. When the user clicks this, they end up instead at https://engineering.deptagency.com/?action=unsubscribe&newsletter=34bb27ba-af93-4374-8e93-aa48e1baddfe&uuid=cf4ec616-4724-446d-86e6-46d3f11628d8. Using this source code helpfully provided by an admin on the Ghost forums, we should be able to programmatically unsubscribe a user from our specific newsletter with the Ghost Admin API.
    (Note, that we would be able to change this domain if we self-hosted the Ghost platform.)

Other things to keep in mind

  1. Redirects. We have 301 redirects set up in the "Labs" section of the ghost admin. This does affect how the unsubscribe URL is currently redirected from our Ghost site to our custom domain:
301:
  ^\/$: https://engineering.deptagency.com
  ^\/(?!assets|ghost|unsubscribe|contact)([a-zA-Z0-9-]+)\/$: https://engineering.deptagency.com/$1
  ^\/contact$: https://deptagency.com/contact
  /why-i-built-a-new-state-management-library-2/: /why-i-built-a-new-state-management-library/
@nring
Copy link
Contributor Author

nring commented Sep 1, 2023

After extracting that source code into our own app, calling the /members/member/newsletters resource directly doesn't work because our site is in private mode. Requests to https://{our-ghost-domain}/members/member/newsletters are redirected to https://{our-ghost-domain}/private/?r={original-url}.

If we want to go down this route, we'll have to both turn off private mode and use a custom theme that doesn't output any views so we don't have duplicate content indexed by SEO robots. I was able to get a similar response from Ghost support:

The most common solution for headless setups would be to use a custom theme which doesn't output any post data on the ghost.io site: thus it cannot be reached or indexed (but should still allow the Ghost generated links for unsubscribes to work as expected).

For example, there is a community generated theme here for this use case specifically.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant