Hello Indie Hacker Devs,
I'm trying to add email sign-up forms in react – both inside a React app and also on my landing page with is built with Gatsby (and therefore React).
I currently see two ways to do this, but neither seems great so I wanted to see what solutions others may have.
Here are my goals:
I haven't picked an ESP yet, but I'm looking at Mailerlite, EmailOctopus, and Sendinblue. I've used Mailchimp in the past which I'm trying to avoid for now.
The two solutions I have are:
Take the email signup embed code from the ESP, remove all CSS styling, react-ify the code (e.g. turn class into className, for to htmlFor, etc.), add the ESP's javascript <script> tag using react-helmet, and add any dom-attached javascript code with useEffect (e.g. document.body.appendChild(script)). This works pretty well, though I'm not a fan of including external scripts. Mailchimp's js script is huge and Mailerlite uses jQuery which I don't want to include unless I have to.
Use a serverless function to take email signup submissions and send the data to the ESP via their API. I'm using Firebase so I could have my website/app send the email signup data to a Firebase Cloud Function to do this. The good thing is now I have total control over the email signup flow. But the problem is now I have to maintain a cloud function, there is an extra moving part that can break, and I have to either manually deal with error/success messages or relay the error/success messages from the ESP's API through the cloud function and back to the web app.
All of this above seems way too complicated for an email signup form, so I'm just trying to figure out if I'm missing something obvious.
How do you handle this?
Any help is much appreciated.
Thanks!
Hi Steven, I have the exact same "problem" and would love to see the code for #1 solution. I Could you mail the code please?
Hey, if by any chance you want to connect this is my email, unfortunatly I cannot message you here daniel.zitarevic @ onet dot pl
Hi Steven, I have the exact same thoughts and looking for an answer.
Did you find any good solution for MailerLite for example?
Cheers!
I ended up going with #1, hacking together the mailerlite form for my react app. Not a great solution because I'm basically embedding the mailerlite js file manually using useEffect. The mailerlite js form uses jQuery which I don't use anywhere else on my site so that's not great. But at least it works. You can see it on my home page https://ormi.io
It was so long ago, I don't remember exactly how or why I did it that way. I can email you the code if you like.
Eventually, I will probably switch to #2 when I have more time to implement it. That way, I will have more control over the code.
Hope that helps!
Thank you for the answer, I was trying to do it with Iframe but then I noticed that they're storing some MailerLite cookies + Google-captcha cookies. I try to make my website cookieless.
I guess your #1 solution will store some cookies as well as you download the code from their server. I also try to avoid downloading non-needed packages.
For now, I ended up just redirecting users to their "landing page" with my form but I'm afraid that it will kill the conversion rate.
Thanks for pointing out the cookies, I totally forgot about those. I don't like cookies either, which is another reason I will probably go with #2 eventually.
I see another problem with the serverless function – you have to secure the form against bots. In the downloaded form, there is an integrated captcha field so you have some protection.
As you mentioned - it's waaay too complicated for such a simple thing and mostly paid services.
I'm not a fan of captchas as a user experience, so my plan to weed out bots was to have a simple honeypot field that the function would check and also require email verification. Don't know if those two things would be sufficient. I suppose if not, then I would add captcha as last resort.
Also, it's possible that other ESPs may have cookie-less embed forms, but I haven't had time to investigate yet.
If you find a good solution, please let me know!
Hi again, in the end I did a serverless function on cloudflare worker.
It connects to MailerLite api and adds a subscriber. No cookies, no jQuery 😎
Cool, thanks for letting me know. I'll probably eventually use that method too, and cross my fingers that spam won't be an issue.