Laravel 5 blade show if localhost


I want to show my google analytics UA code based on localhost (local development) or live server. I think there are a few options such as storing the UA code in the .env file but i’d prefer to just have an if else statement in the blade file for the head layout.


laravel blade if localhost (i use an alias local. but you can change that to localhost if you want).
      @if (Request::is(‘local/*’))
        ga(‘create’, ‘UA-788xxx55-4’, ‘auto’); //live
        ga(‘create’, ‘UA-788xxx55-5’, ‘auto’); //localhost
laravel blade if localhost
Full Stack 4U

Full Stack 4U shares web development tips for full stack web technologies and is helping share the passion to web developers worldwide.

Leave a Reply

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