What's your biggest current challenge? Have your say in Community Polls along the right column.

Know which page the customer filled the contact form on

Solved

Know which page the customer filled the contact form on

Shams123
Excursionist
13 1 4

Hello There,

My shop is hoponturkey.com and I have a get a quote form at every product page because we don't sell physical products rather customized services and there are no fixed prices and the aim is to get customers to contact us and ask about the price.

The main issue is that when a customer fills out the contact us form on one of the pages, I get an email telling me what the message was, the email of the customer and the basic info, but it doesn't tell me which page they filled the form on which is vital for my business since they would be asking about a particular service and wanting to get a price but I don't know which service, I would really appreciate if someone can tell me what to add but check the website before because I have a whole different thing going on there, I don't have an add to cart nor buy now nor prices there, only a contact form.

Thanks in advance

Accepted Solutions (2)

JohnAtFisharply
Tourist
4 1 1

This is an accepted solution.

So I'm just getting started on my own shop, but I believe that I have one method to accomplish this. On the product page where you've put the form, I think the product object information is available. You can, therefore, modify the form so as to include a (hidden, if you want) form field to pass on the product.title or other data about it ala {{ product.title }} or any other attribute. No guarantees, but may be worth looking into. 

View solution in original post

BrianAtWork
Shopify Partner
245 59 188

This is an accepted solution.

Hey @Shams123 ,

 

It looks like @JohnAtFisharply is on the right track! You will need to edit your 'product-template.liquid' file and add some code. This will get the product/service to be included in your contact form emails. Here's a quick how-to:

 

Before you customize your theme:

 

  • Duplicate your theme to create a backup copy. This makes it easy to discard your changes and start again if you need to.

 

Edit your theme code

 

  1. From your Shopify admin, go to Online Store > Themes.
  2. Click Actions > Edit code.
  3. In the Sections directory, click product-template.liquid.
  4. Find the submit button code that looks like:
    <input type="submit" class="btn right" value="{{ 'contact.form.send' | t }}">
  5. Right above the submit button code, paste this code:
    {%- if product and product.title -%}
       <input type="hidden" id="contactFormProduct" name="contact[product]" value="{{ product.title }}">
    {%- endif -%}
  6. Click Save.

 

That's it! Do let me know if this solved your problem or if you need further help.

 

Brian | Shopify Partner | Ecommerce Consultant
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution  
 - Need further assistance? Visit www.BrianAtWork.com

View solution in original post

Replies 7 (7)

JohnAtFisharply
Tourist
4 1 1

This is an accepted solution.

So I'm just getting started on my own shop, but I believe that I have one method to accomplish this. On the product page where you've put the form, I think the product object information is available. You can, therefore, modify the form so as to include a (hidden, if you want) form field to pass on the product.title or other data about it ala {{ product.title }} or any other attribute. No guarantees, but may be worth looking into. 

BrianAtWork
Shopify Partner
245 59 188

This is an accepted solution.

Hey @Shams123 ,

 

It looks like @JohnAtFisharply is on the right track! You will need to edit your 'product-template.liquid' file and add some code. This will get the product/service to be included in your contact form emails. Here's a quick how-to:

 

Before you customize your theme:

 

  • Duplicate your theme to create a backup copy. This makes it easy to discard your changes and start again if you need to.

 

Edit your theme code

 

  1. From your Shopify admin, go to Online Store > Themes.
  2. Click Actions > Edit code.
  3. In the Sections directory, click product-template.liquid.
  4. Find the submit button code that looks like:
    <input type="submit" class="btn right" value="{{ 'contact.form.send' | t }}">
  5. Right above the submit button code, paste this code:
    {%- if product and product.title -%}
       <input type="hidden" id="contactFormProduct" name="contact[product]" value="{{ product.title }}">
    {%- endif -%}
  6. Click Save.

 

That's it! Do let me know if this solved your problem or if you need further help.

 

Brian | Shopify Partner | Ecommerce Consultant
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Click Accept as Solution  
 - Need further assistance? Visit www.BrianAtWork.com

Shams123
Excursionist
13 1 4

Thank you guys very much, it worked like a charm. However, just for anyone reading this in the future, if you have removed the add to cart and buy now buttons from your store, and added only a form for customers to contact you, you might have a different Products template, so you must change to that template not the product-template.liquid the gentlemen suggested.

Thank you guys once again

joelan
Visitor
1 0 0

Brian, I would like to add size and color to the email, is there a way to add them?

xma
Visitor
2 0 2

Thank you your code worked for me!! Took some time for me to figure it out as someone without coding knowledge but I was able to change the contact form so that I know which page (not necessarily product) the form was submitted, by adding the following to the contact form section code:

 

{%- if page_title -%}
<input type="hidden" id="contactFormPageTitle" name="contact[page title]" value="{{ page_title }}">
{%- endif -%}

 

This was based on your code and luckily I got it to work!

Hihumialex
Visitor
1 0 0

Thanks so much for this, works perfect and it was just what I was looking for.

LeaveaMessage
New Member
5 0 0

Hi Shams,

I’m glad that you solved your problem. If you will look for a tool which gives you functionality of personalized contact form on every page in your store which is a simple ticket system (in ticket you will get information about the url where the message was sent), you can try Leave a Message. I am sure that the installation process will be easier!