Shopify: How to add user as subscriber from contact form?

Viewed 590

I have tried searching but so far haven't been able to find a solution that doesn't involve paying for an app or using a third party form. So if anyone has a solution to this I'd be so happy.

I need to include a checkbox on the standard contact form on a contact page page.contact.liquid. I understand how to add fields, but I want the checkbox, when checked to automatically add the user to our subscriber list.

I have tried adding the below, hidden field, but it doesn't add a subscriber. It doesn't seem to do anything.

<input type="hidden" name="customer[accepts_marketing]" id="hiddenMarketingCheck" autocorrect="off" value="true" >

I did look at the code in the subscriber form section and noticed that the two forms are tagged differently using form_type. So I did some testing and changed the form type from contact to customer. So basically the output goes from this <input type="hidden" name="form_type" value="contact"> to this <input type="hidden" name="form_type" value="customer">.

That 'half works', because it does achieve my original goal to add a user to the 'customer accepts_marketing'. But then it doesn't send the message to the admin user of the site. So now it doesn't work as a contact form.

Does anybody know how I can achieve this? Maybe there are other form types I can use? Or additional fields I need to add?

Any help will be much appreciated.

Many thanks in advance.

1 Answers

My suggestion would be not to add the users at this stage, however, what I did on one of my projects was to put the subscription field AFTER they submitted the contact form and on the success message box.

This way you give them a clear option and understanding that they are subscribing with you and you didn't force them to do so.

I had a much higher acceptance than simply opting in the user.

Related