If you're using gtag.js then your code snippet for implementation will look something like this:
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-00000000-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-00000000-1'); //modify this line
</script>
To prevent it from sending a pageview on load you just make the adjustment like so:
gtag('config', 'GA_MEASUREMENT_ID', {'send_page_view': false}); //replace the id with your own id
For SPAs, I'd recommend Google Tag Manager instead and use datalayer events or the included history change trigger for tracking, there might be a slight learning curve to start, but I think it'll simplify your code and make it more "portable" should you switch analytics platforms later on.
More info on GTM: https://developers.google.com/tag-manager/devguide
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…