About reading mtm parameters from session


I’d like to know how to read mtm parameters in php, but not from querystring. Why?

For example, a visitor enters my website from a link like this: https://agenziaimmobiliare.website/?mtm_campaign=test

The user fillup a form and send an email. In the email I’d like to have the mtm_campaign parameter, so I exactly know from which campaign the email is from. I can do this reading querystring url with php. No problem.

The real problem is that if the user browse other pages, mtm_campaing parametrer disappears from url and I cannot read it to write it in the email. Are there some session variables to read?

Any suggestion?

You can set the mtm_campaign value in the session cookie of your website.
Then PHP has just to read this session cookie :wink:

OH! Thankyou, this could be a simple and elegant solution.

I prefer do not use cookies because users can stop them with cookie banner.

Infact, I use Matomo without cookies so I can have traffic data also for users that disable cookies.

This is why I was looking for session variables or something similar.

Is there a solution without cookies?

This is part of a project of my agency to leave GA3 and GA4 definitely.

Thankyou ver much for your help

As the cookie is not third party cookie and does not store personal data (campaign ID is not personal data) and the cookie live duration limited to the session, I think you can use this solution without cookie banner. (a simple info in the about us page would be sufficient)

Yes, you are right.

Thank you very much for your suggestion.