Jump to content

MarcLee0807

Member
  • Posts

    1
  • Joined

  • Last visited

Posts posted by MarcLee0807

  1. On 7/4/2021 at 12:51 AM, creedon said:

    Add the following to Page Settings > Advanced > Page Header Code Injection for the page.

    <script>
    
      /*
      
        begin add class(es) to button
        
        Version    : 0.1d0
        
        SS Version : 7.1
        
        By         : Thomas Creedon < http://www.tomsWeb.consulting/ >
        
        */
        
        // enter button block id without the #
        
        const buttonBlockId = '[enter button block id without the # here between single quotes]';
        
        // do not change anything below, there be the borg here
        
        window.addEventListener ( 'DOMContentLoaded', ( ) => {
        
          document.querySelector ( '#' + buttonBlockId + ' a' )
          
            .classList
            
            .add ( 'button', 'wt-embed--trigger' )
            
          } );
          
        /* end add class(es) to button */
        
      </script>

    Let us know how it goes.

    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>

     

×
×
  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.