mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-24 11:22:19 +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 | ||
api-version-compatibility | ||
auth | ||
custom-redirects | ||
frontend-data-service | ||
mega | ||
members | ||
newsletters | ||
notifications | ||
permissions | ||
posts | ||
route-settings | ||
settings | ||
settings-helpers | ||
staff | ||
stripe | ||
themes | ||
url | ||
users | ||
webhooks | ||
labs.test.js | ||
limits.test.js | ||
nft-oembed.test.js | ||
slack.test.js | ||
xmlrpc.test.js |