This code works for me just fine. Anyone who is struggling with adding Hubspot CTAs 'Trigger on button click' code snippet to external pages. Look up this code.
My snippet was 'hs-cta-trigger-button hs-cta-trigger-button-117565208857', and I put them like '.add ('hs-cta-trigger-button', 'hs-cta-trigger-button-117565208857'). Other than that, I only entered block ID without # as the instruction explained.
Below is my code. I hope it helps.
<script>
const buttonBlockId = 'block-9fe7a9eb09a9282784ff';
window.addEventListener ( 'DOMContentLoaded', ( ) => {
document.querySelector ( '#' + buttonBlockId + ' a' )
.classList
.add ( 'hs-cta-trigger-button', 'hs-cta-trigger-button-117565208857')
} );
</script>