mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-28 21:33:24 +03:00
a7b583050c
closes https://github.com/TryGhost/Team/issues/1908 ### Problem: - We need tracking on the paywall links in each email. (we cannot ignore them because those buttons are probably gonna have a higher paid conversion attribution than others). - Currently we only add the paywall HTML to an email when processing each batch. So if we batch an email to 1.000 recipients per 100, we'll generate the paywall HTML 10 times. - We cannot replace links in `renderEmailForSegment` because that methods will get called multiple times. We don't want to have multiple redirect instances created for the same link in the same email. ### Solution: - Move the generation of the paywall to the `serialize` method of the post email serializer. - Surround the generated paywall with HTML-comments so we can remove it if required in `renderEmailForSegment` depending on the member segment we are sending the email to. --- ### Before: **Serialize output:** ```html <html> <body> <h1>Generated email header</h1> <p>Generated text</p> <div> <!-- POST CONTENT START --> <h1>Post title</h1> <p>Content visible for all members</p> <!--members-only--> <p>Content visible for paid members only</p> <!-- POST CONTENT END --> </div> </body> </html> ``` To be modified later by `renderEmailForSegment`: **Paid members (nothing changed):** ```html <html> <body> <h1>Generated email header</h1> <p>Generated text</p> <div> <!-- POST CONTENT START --> <h1>Post title</h1> <p>Content visible for all members</p> <!--members-only--> <p>Content visible for paid members only</p> <!-- POST CONTENT END --> </div> </body> </html> ``` **Free members (paywall _added_):** ```html <html> <body> <h1>Generated email header</h1> <p>Generated text</p> <div> <!-- POST CONTENT START --> <h1>Post title</h1> <p>Content visible for all members</p> <h2>Generated paywall here</h2> <a href="https://subscribe.com">Subscribe to read the full post</a> <!-- POST CONTENT END --> </div> </body> </html> ``` ### After this change: **Serialize output:** ```html <html> <body> <h1>Generated email header</h1> <p>Generated text</p> <div> <!-- POST CONTENT START --> <h1>Post title</h1> <p>Content visible for all members</p> <!--members-only--> <p>Content visible for paid members only</p> <!-- PAYWALL --> <h2>Generated paywall here</h2> <a href="https://subscribe.com/?tracked">Subscribe to read the full post</a> <!-- POST CONTENT END --> </div> </body> </html> ``` To be modified later by `renderEmailForSegment`: **Paid members (paywall removed):** ```html <html> <body> <h1>Generated email header</h1> <p>Generated text</p> <div> <!-- POST CONTENT START --> <h1>Post title</h1> <p>Content visible for all members</p> <!--members-only--> <p>Content visible for paid members only</p> <!-- POST CONTENT END --> </div> </body> </html> ``` **Free members (members-only content removed):** ```html <html> <body> <h1>Generated email header</h1> <p>Generated text</p> <div> <!-- POST CONTENT START --> <h1>Post title</h1> <p>Content visible for all members</p> <!-- PAYWALL --> <h2>Generated paywall here</h2> <a href="https://subscribe.com/?tracked">Subscribe to read the full post</a> <!-- POST CONTENT END --> </div> </body> </html> ``` |
||
---|---|---|
.. | ||
adapter-manager | ||
admin | ||
api-framework | ||
api-version-compatibility-service | ||
bootstrap-socket | ||
constants | ||
core | ||
custom-theme-settings-service | ||
domain-events | ||
email-analytics-provider-mailgun | ||
email-analytics-service | ||
email-content-generator | ||
express-dynamic-redirects | ||
extract-api-key | ||
html-to-plaintext | ||
job-manager | ||
link-redirects | ||
link-replacement | ||
link-tracking | ||
magic-link | ||
mailgun-client | ||
member-analytics-service | ||
member-attribution | ||
member-events | ||
members-analytics-ingress | ||
members-api | ||
members-csv | ||
members-events-service | ||
members-importer | ||
members-ssr | ||
minifier | ||
mw-api-version-mismatch | ||
mw-cache-control | ||
mw-error-handler | ||
mw-session-from-token | ||
mw-update-user-last-seen | ||
mw-vhost | ||
oembed-service | ||
offers | ||
package-json | ||
payments | ||
security | ||
session-service | ||
settings-path-manager | ||
staff-service | ||
stripe | ||
update-check-service | ||
verification-trigger | ||
version-notifications-data-service |