They want me to add this code somewhere on the page (ex header)
<!-- Calendly link widget begin -->
<link href="https://calendly.com/assets/external/widget.css" rel="stylesheet">
<script src="https://calendly.com/assets/external/widget.js" type="text/javascript"></script>
<!-- Calendly link widget end -->
Then they want me to create a button with this code
the only solution I can come up with right now is to drag in a HTML embed box and write some code to make a custom button. I just tested with this and it seems to be working fine;
If you want create and style the button in Webflow, you can add some custom code (plain JavaScript) with an embed anywhere on the page, to listen for the click on that element (I gave the button an ID of calendyButton, in the designer, then used that in the code example. The script will fire off the widget overlay when your custom button is clicked:
Make sure you replace the url: value of youraccount with your calendy Account settings → My link → value in the script.
@krubens I think he meant for you to add a standard webflow button with the ID “calendyButton” and then add an Embed with the JS code anywhere on the page.
I did. Nice catch. Just more time in the ring @robingranqvist. Of course, you could use any ID you want. Just needs to be unique and match in the script.
Make sure you replace the url: value of youraccount with your calendy Account settings → My link → value in the script. That will resolve the issue.
This is excellent! I was trying to do the same thing and this is working nicely. The only challenge I’m having is that it works great for the first instance of the button on the page, but doesn’t work for an identical button further down the page. same link, same button. Just adding a second CTA at the bottom so you dont have to scroll back up. Any thoughts?
The code was written to target an element by its ID. On a page ID’s must be unique in the HTML spec. If one wanted to trigger the code with multiple targets, the code would need to be refactored to use a class name like below. Note the class is lowercase (Webflow changes it on publish). In this case that would be “calendybutton”.
This is exactly the same problem I’m currently having, and I’m thankful there are some great responses here - although I’ve not had any luck getting this working.
The only difference is, I’m trying to do it with the Pop-up text option instead.
<link href="https://calendly.com/assets/external/widget.css" rel="stylesheet">
<script src="https://calendly.com/assets/external/widget.js" type="text/javascript"></script>
<!-- Calendly link widget end -->
I have multiple buttons on the page that I’d like to trigger the popup (and have noted I have to get the button by classname instead of ID to do this), however I thought I’d get the script working before tinkering with the buttons.
Hi, I have added the code as you’ve stated to integrate Calendy to a button click but I’m not having any joy? Are you able to shed any light? Below is the share link for my site. Thanks in advance.
I’ve tried just about everything on the page here to some extent or another, but can’t seem to get it going. My intent is to put the link on the “Book Now” buttons.
I just tried the solution with .getElementsByClassName for multiple elements from @webdev, but it did not work for me. After tuning it a bit I found a way to really select all elements with the same class name.
Just use this:
This text will be hidden <script> var calendyButton = document.getElementsByClassName('calendlybuttonclass'); var counter; for (counter = 0; counter < calendyButton.length; counter++) { calendyButton[counter].addEventListener("click", function() { Calendly.initPopupWidget({ url: 'https://calendly.com/monishabajaj' }); return false; })} </script>