Skip to main content
Tutorial Free

Adding unspecified GET parameters to Routes

July 17, 2017
1 min read
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:
Route::get('/', 'HomeController@index')->name('homepage');
And then we add a link to it:
Home
Now, what if you want to track this link with UTM parameters? Of course, you can do it like this:
Home
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:
Home
Or, even better, pass these values as array of $utm_parameters and then have this:
Home
The result URL will be the same: /?utm_source=internal&utm_medium=banner&utm_campaign=onboarding2017 Hope that helps!

Enjoyed This Tutorial?

Get access to all premium tutorials, video and text courses, and exclusive Laravel resources. Join our community of 10,000+ developers.

Recent Courses on Laravel Daily

Testing in Laravel 13 For Beginners

26 lessons
1 h 41 min read

Laravel 13 Eloquent: Expert Level

41 lessons
1 h 34 min

Queues in Laravel 13

18 lessons
1 h 12 min read

No comments yet…