Write Code automatically in the Head of all pages

If you use Google Analytics, a Cookie Consent tool or other stuff you need to put the same pice of code in the of all pages. Is there a way to do that automatically with Pinegrow?

If not, that would be a great feature. Maybe the user could write code in the settings that will be automatically included in the head of all pages. Or does such a feature already exist?

I think it’s possible with a .htacces?

Hi @Riccarcharias,
I guess it would depend on how many different items you want on each page which direction you could take. As usual, there are multiple ways to accomplish tasks in Pinegrow.

You could set up a Master page. This would probably be most useful if there are a number of different elements in both the head and body.

You could also just add your various bits of code as components in the Library. This would require you to drag the “core” elements to each page, but is probably a better way if you are going to be using those same components in multiple projects.

Hope this helps!
Bob

1 Like

Hello,

Thanks so much for your help @RobM! I would withdraw my feature request :smiley: Using Masterpages is a good idea. Using the Head as a component is an even better idea for pages you don’t want to use a masterpage.

This is where PHP is so handy

<?php include('google.php'> Where the file google.php contains the analytics scripts. I use a template for 'standard' pages that includes includes for header/footer
1 Like