Jump to content

[SOLVED] How to add parameters from HTTP_REFERER to current URL?


Alexenn

Recommended Posts

Hello,

 

first of all i'm using Prestashop 1.7.

 

I'm using paid SEO from google adword and I would like to have more informations about where the customer is coming from when he uses the contact form.

I found an interesting setting to do that in google adwords called "URL options", basically it's gonna add parameters to the link the paid ad is pointing to.

For example when ad is pointing to the url:

example.com/some_category/259-some_product.html

 when clicking the ad google is going to add parameters like this:

example.com/some_category/259-some_product.html?Google_ad=1&adgroupid=21

 

So i'm wondering how I could make it so these parameters are copied in the URL of every pages the customer is going, so when he fills in the contact form I can just extract those parameters and add them to the mail body.

Do I have to override and modify almost every functions in the Link.php class? is there another way?

 

Thanks!

Edited by Alexenn
Solved (see edit history)
Link to comment
Share on other sites

  • 2 weeks later...

I think the cleanest solution would be to save those variables in a cookie, and add it to the contact form message.

You can check the $REQUEST in FrontController.php, as it gets executed in every page, and if they are set, save them to a cookie.

Then, modify the contact form controller to read the cookie data, and if it is set, add it to your message

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Thanks for your answer !

Great idea, I never thought about using cookies for some reasons, that's a way better solution.

Not sure what to do with the $REQUEST though, I'm going to just use $_GET to check if a page has a "get" parameter in its url. Would it be cleaner to manipulate $REQUEST?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...