Jump to content

Activate third-party widget with button in header

Go to solution Solved by Beyondspace,

Recommended Posts

Hi, I'm trying to get a third-party widget to activate with the BOEK NU (book now) button in the header. Unfortunately, I have only been able to link this to a separate booking page with the IN-LINE widget, which is not what I want.

The widget should 'slide-in' from the right-hand side of the page. For this, I received the code below.

Could somebody help me with this?

Regards,
Patrick

Website: somatichub.nl
Pasword: SS2024!


<button id="widget-button">Boek nu</button>

<script src="https://cdn.jsdelivr.net/npm/appybee-widget"></script>

<script>
    AppyBeeWidget.init({
        companyAPIKey: 'f3a4a372f989b69e66e4bfb0a438b0b3',
        style: 'side',
        locale: 'nl'
    });
</script>

<script>
    var button = document.getElementById("widget-button");
    button.onclick = function() {
        AppyBeeWidget.show();
    };
</script>
 

Link to comment
  • Replies 6
  • Views 630
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

16 minutes ago, Patrickvhnederend said:

Hi, I'm trying to get a third-party widget to activate with the BOEK NU (book now) button in the header. Unfortunately, I have only been able to link this to a separate booking page with the IN-LINE widget, which is not what I want.

The widget should 'slide-in' from the right-hand side of the page. For this, I received the code below.

Could somebody help me with this?

Regards,
Patrick

Website: somatichub.nl
Pasword: SS2024!


<button id="widget-button">Boek nu</button>

<script src="https://cdn.jsdelivr.net/npm/appybee-widget"></script>

<script>
    AppyBeeWidget.init({
        companyAPIKey: 'f3a4a372f989b69e66e4bfb0a438b0b3',
        style: 'side',
        locale: 'nl'
    });
</script>

<script>
    var button = document.getElementById("widget-button");
    button.onclick = function() {
        AppyBeeWidget.show();
    };
</script>
 

Where are you put these above codes? I check on your home page but can not find them

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment
57 minutes ago, Beyondspace said:

Where are you put these above codes? I check on your home page but can not find them

I didn't put it on the home page, as I can't put them as part of the BOEK NU button in the header.

 

Do you want me to make a temp button with this? As long as it is not in the header, it works.

Let me know

Link to comment
  • Solution
Posted (edited)
33 minutes ago, Patrickvhnederend said:

I didn't put it on the home page, as I can't put them as part of the BOEK NU button in the header.

 

Do you want me to make a temp button with this? As long as it is not in the header, it works.

Let me know

Try adding to your footer code injection

<script src="https://cdn.jsdelivr.net/npm/appybee-widget"></script>
<script>
  AppyBeeWidget.init({
    companyAPIKey: 'f3a4a372f989b69e66e4bfb0a438b0b3',
    style: 'side',
    locale: 'nl'
  });
</script>

<script>
  const btns = document.querySelectorAll('header a[href="/book-now"]');
  if(btns.length) {
    btns.forEach(button => {
      button.onclick = function(e) {
        AppyBeeWidget.show();
        return false; /*preventDefault*/
      };
    })
  }
</script>

<button id="widget-button">Boek nu</button> on your above code can be removed

Edited by Beyondspace
add preventDefault for clicking

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment
11 minutes ago, Beyondspace said:

Try adding to your footer code injection

 

Thanks. I added your code.

I slides in, but then loads the BOOK-NOW page, therefore the widget disappears again.

 

Is it possible to not link it to a page, so I can omit the extra booking page?

Link to comment
9 minutes ago, Patrickvhnederend said:

Thanks. I added your code.

I slides in, but then loads the BOOK-NOW page, therefore the widget disappears again.

 

Is it possible to not link it to a page, so I can omit the extra booking page?

I've just updated my code, try again and let me know how it works

BeyondSpace - Squarespace Website Developer

🖼️ Lightbox Studio (Enable Pinch/Zoom on lightbox)
🗓️ Delivery Date Picker (Squarespace Date picker form field)
💫 Gallery block 7.1 workaround
🥳 Sparkplugin Customisations Browsers (Browse +100 Spark plugin customisations)
🥳 Elfsight Template Browsers (Browse +1000 Elfsight widget Templates)

If you find my answer useful, let's leave a like or upvote so others with the same issue can find their solution. Thank you!

 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

×
×
  • 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.