mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-28 14:03:48 +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> ``` |
||
---|---|---|
.. | ||
e2e-api | ||
e2e-browser | ||
e2e-frontend | ||
e2e-server | ||
e2e-webhooks | ||
integration | ||
regression | ||
unit | ||
utils | ||
.eslintignore | ||
.eslintrc.js |