How to set up Google tag Manager configuration in ASP NET Core razor pages

I am very new to ASP NET Core razor pages. I have a requirement to set up Google Tag Manager in ASP NET Core razor pages. Usually in the ASP.Net solution we use Google Analytic’s tag.js script in page load. In angular we usually set up in app.module.ts/ app.component.ts.

But, I am to set up GTM tracking code/ id in ASP NET Core razor pages.

After set up, I need to send triggering conditions to GTM (like on button click send a event trigger to GTM so that it will in turn call the Google Analytics set up tag). Is there any helper class or plugins which I can use for the same ? Or in which file like Startup.cs , I can use the GTM configuration set up ?

Thank you.