Installing Google Tag Manager/LinkedIn Insights Tag using coded components

Hi,

We are looking to install Google Tag Manager and the LinkedIn Insights Tag in our app, but to install it we need to add some code snippets to the HTML at specific places. For the Google Tag Manager we need to add the script to the <head> element (which works well through the env config page in Appfarm) and directly below the opening <body> tag. For the LinkedIn tag it should be directly above the closing <body> tag.

I guess the closest we get through the UI Editor is using coded components, but since we can only add these inside “views”, they will be nested quite far down the hierarchy.

Is there any recommended way for doing this? We have set up GA4 already, which only needs the script to be added in the <head> element, and it seems to work well.

Hi!

Thank you for reaching out! Since you’ve already have GA4 up and running, you could possibly try to implement the Linkedin Insights tag using Google Tag Manager.

Let us know if this is a possibility.

Hi Shahitha,

Thanks for your reply! I see now that the community supports HTML and Markdown, so all the HTML element descriptions dissapeared from my question. Edited now, hope it makes the question clearer.

We have installed the GA4 tracking code, but need to install the Google Tag Manager container code as well.

Hi!

The <noscript> tag of the Google Tag Manager does not have to be the first direct child of the <body> tag. It is recommended to place it as early as possible. So, a coded component could be placed in the top if your default view. The <script> tag should be placed in the header, hence it should be uploaded to the script sources setting in Environment Config.

However, the <noscript> tag is used for browsers not supporting javascript. Appfarm does not work on browsers not supporting javascript. So the <noscript> part of the setup is probably something you will not need to consider.

Hi Kristian,

Great, thank you for clearifying. In that case there shouldn’t be any real issue with dropping the <noscript>. This plus adding the correct LinkedIn and Google URLs to the CSP allowlist under “Content Security” solves it.

Thank you Kristian and Shahitha!

1 Like