additional

Adding unspecified GET parameters to Routes

A quick tip for the case if you need to add additional GET parameters to your route URL, but don’t want to specify them in Routes file. Apparently, there’s a simple way.

Let’s imagine we have this route:

And then we add a link to it:

Now, what if you want to track this link with UTM parameters?

Of course, you can do it like this:

But probably the logic of your campaign is defined outside of Blade view, so it would be convenient to pass these variables somehow. Guess what – we can write them as array:

Or, even better, pass these values as array of $utm_parameters and then have this:

The result URL will be the same:
/?utm_source=internal&utm_medium=banner&utm_campaign=onboarding2017

Hope that helps!

Liked the article? Maybe you need help with your Laravel project?
Our LaravelDaily Team can help!

2 thoughts on “Adding unspecified GET parameters to Routes

  1. Unrelated to Laravel – I hope you don’t use this GA campaign to measure internal clicks – it creates a new session for you. Try ‘internal promotions’ from enhanced ecommerce instead.

Leave a Reply

Your email address will not be published. Required fields are marked *