We are in the process of trialling GitLab CE but need to tweak/customise a few elements.

Our developers are configured with the “developer permission/role” which unfortunately means they cannot create new projects. To get around this, we created a user/bot with the relevant permissions and a custom HTML page which uses the API to create a new project based on the user input.

I am not familiar with the ruby/slim syntax and struggled to modify the new project page as desired. We use GoogleTagManager fairly extensively in our work so decided it would probably be easiest to implement this throughout GitLab so our customisation could all be ring-fenced within GTM,

Adding GoogleTagManager to GitLab was fairly straight forward- adding 2 lines of code to;

 sudo nano /opt/gitlab/embedded/service/gitlab-rails/app/views/layouts/_head.html.haml

…below the %head tag, two %meta tags follow then we insert our javascript tag;

- page_description brand_title unless page_description

- site_name = "GitLab"
%head{ prefix: "og: http://ogp.me/ns#" }
  %meta{ charset: "utf-8" }
  %meta{ 'http-equiv' => 'X-UA-Compatible', content: 'IE=edge' }

  :javascript
    (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src='https://www.googletagmanager.co$

 

I have truncated the javascript- please ensure you paste the full code (from between the <script> tags presented by GoogleTagManager). Please also note the importance of the whitespace at the start of each line in the .haml file (the :javascript line should have 2 spaces before and the next line 4 spaces before).

I had to to issue a restart command to see the changes reflected in the front-end;

sudo gitlab-ctl restart

That’s it!

Do note that your changes may/will likely be lost if/when you update.

I hope we didn’t miss an obvious/easy/out of the box mechanism for adding GoogleTagManager to GitLab?