Add global code & meta tags to header or footer

Todays web design demands that I be able to add code to my pages at certain places, like in the head tag, or at the very end of the page. Blocs doesn’t handle this too well. There is a feature to add code to a single page and then choose either header or footer, but if I want to add a global code (cookie consent, script for a chat service, etc.) I pretty much have to do it by hand - esp. if I want the code to go at the end.

At the moment I am misusing the “Analytics Code” setting in the global site settings to add a whole bunch of other code besides just analytics. It works OK, but it’s kind of a hack.

So my wish is:

  1. Global Code: add code to either the head or at the end on a global basis for every page on a site.
  2. Global Meta: be able to add meta tags like keywords on a global basis for every page on the site.

The single page code setting should remain - that way I can still add a script that is specific to a certain page.

1 Like

You could add all the code you wish globally by adding a code bric into the global area of your page - this should then transfer to every page you add. Doing it this way, you can set where in each page the code should be placed (header, footer, before doctype etc.) Not actually tried it, but worth trying.

1 Like

You can use a code bric, then select Project header or footer from the drop down option in the code editor.


Yea, but that’s still on a page to page basis, right?

Nope project settings are for all pages. Page settings are page by page

1 Like

Ok that’s a workaround. I will still add a wish to the wishlist for this to be a feature in the site settings. Just seems the logical place to put it, esp. when you consider that there is already a feature for adding “analytics” …

1 Like

Agreed. For now, I too just use Analytics Tracking Code in the Project Settings because it is faster and easier than adding an HTML widget. Speed is everything.

By the way, that field in Analytics Tracking Code is a minor bother because when Return closes Project Settings. The good news is that if you press Option-Return, you’ll get a new line. Even so, having a built-in feature would be welcomed. Or maybe rename “Analytics Tracking Code” to “Global Code”? Anyway, I’m surprised I alone hearted❤️ this great Wish List request.

1 Like

Does that mean, that I can use the “Analytics Tacking Code” for both the cookie-note code as well as the analytics tracking code?

I don’t know what “cookie note code” is, but any code you want globally applied to every page in your Blocs website should be placed inside the Analytics Tracking code “field” within Project Settings. That’s precisely why I suggested that field be renamed “Global Code” to make it easier to understand. The current naming is misleading users into thinking that field only works for Analytics code, which is incorrect.

1 Like

That is not a good idea at all. The Analytics field puts that code between the <head> </head> tags. You should only put certain things here.

EG. if you put Javascript here, it can slow your page load down and is bad practise. Hence why we usually place that code at the bottom just before the closing body tag.

I am NOT using JS there. I am using the following:

.tricolor-grad {
background: rgb(0,0,0);
background: -moz-linear-gradient(90deg, rgba(0,0,0,1) 10%, rgba(130,43,0,1) 50%, rgba(0,0,0,1) 90%);
background: -webkit-linear-gradient(90deg, rgba(0,0,0,1) 10%, rgba(130,43,0,1) 50%, rgba(0,0,0,1) 90%);
background: linear-gradient(90deg, rgba(0,0,0,1) 10%, rgba(130,43,0,1) 50%, rgba(0,0,0,1) 90%);

I want that to appear on every page in the site, and using that Analytics Tracking Field makes it EASY to globally apply to every page in the site. There are other ways, but none of those ways are as easy. And again, that is why I strong suggest we have a GLOBAL means of adding code to a Blocs site that would allow us to specify into which tag we want that code inserted.

Softpress Freeway has empowered me to do that for decades…

1 Like

You said

Which is a bad suggestion and could cause someone problems.

“Any CSS styling code.” :slight_smile:

I agree 1000%

1 Like

For the new european cokkie-notice requirements i have to put those scripts into the Blocs-Projekt:

This is from Cookiebot. I did put the first one now in the “Analytics-Tracking-Code”-field and the second one in the footer, and that one I turned out the visability on all devices.

The Cookie-Note does appear, but if one does not click on the Cookie-Note button and goes to another page on the Website, the pages won’t load any more. Am I doing something wrong?

1 Like

Law or no law, cookie notifications on websites are the bane of humanity! I absolutely hate to visit websites only to get slapped in the face with those bothersome notices. I never want to click Accept but instead search for a close box or click the Reader View icon to grab website text and filter out those notices (and any silly ads that obscure my view).

We human beings create too many stupid laws only because we have the best intentions in mind. We need to elect people into office who get rid of existing laws, rather than create new ones.

It’s nice we have forums like this to discuss ways to comply with stupid laws, but the sheer stupidity of the core issue remains.

I totally agree with you! It’s so annoying! I have noticed, that a lot of Websites, also from big companies, still have got the old cookie notice. It is just too much …

1 Like

Hi @Magga
still need help to insert the code?

Yes, actually this problem is still u not solved. I now did put the old cookie notice on the website, till I find a solution for the new one.

OK, for the first code you have two options to try. When you put the first code in the page settings of your index page, the cookie banner will show the message when you go to your homepage. But when Google find more of your sites ( for example ) or something like this and click direct on this link the cookie message not shown ( so I think ). Better is. to set the code in the project settings header.

  1. Insert on your index site a html bric. Switch of preview and set the padding to none.

Bildschirmfoto 2020-03-08 um 10.56.37

Insert the code in the project header

Then go to your Datenschutz site … Do you create the code for Datenschutz with html and the code bric ?

Then open the bric and insert the code in the section with the cookies …later the code will show what cookies were used on your page …


Update: Not sure if you see the banner in blocs preview …