170
Views
8
Comments
How to add a script at the header level
Question

Hi,

I have made an application and now I want to add a script at the header level :

<script>

var _p = window._paq = window._paq || [];

_p.push(['trackPageView']);

_p.push(['enableLinkTracking']);

(function() {

var u="https://mat.fr/";

var d=document('script'), s=d.getElementsByTagName('script')[0];

g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s);

})();

</script>


any idea please ?


thanks

2023-09-06 07-26-35
Sudip Pal

Hey you,

Please check the below snip.It will help you.


Thanks & Regards,

Sudip Pal

UserImage.jpg
you asen

thanks for coming back,

I did what you suggest :

but I dont see it at the Required script level :

isit normal ?

2023-09-06 07-26-35
Sudip Pal

Hey,

Is there any create option like the below snip?

Thanks & Regards,

Sudip Pal

2023-09-06 07-26-35
Sudip Pal

Hey,


This is another approach that you can try.

Thanks & Regards,

Sudip Pal

UserImage.jpg
you asen

Hi,

thanks but I need to do that for every page ?

2020-11-13 07-48-15
Khuong Truong

Hi,

If you want to apply for every page, I think you can add the JavaScript widget into OnReady event of your Layout block.

Regards,

Khuong

UserImage.jpg
Filipe Gama

Hi Khuong Truong,


I also tested the solution, and it is working. However, Matomo only registers visits after refreshing the pages. I have this example where I have a button that leads to a second page. When I access the second page through this link, it doesn't register as a visit. Do you know why this happens or how I can resolve it? Thank you. 

UserImage.jpg
Vrushali Punekar

Hi @you asen ,

You can load external JavaScript by adding it on Script folder under Interface tab and then add the script on the screen using Required scripts option.

Additionally, if you need to use JavaScript code, you can use JavaScript element which is available in client action.

I recommend to refer below URL for better understanding.

https://success.outsystems.com/documentation/11/extensibility_and_integration/javascript/extend_your_mobile_and_reactive_apps_using_javascript/


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.