Skip to main content

trigger callbacks

Trigger callbacks when someone share their email.

Status: Completed6 comments

Comments6

  • Vera Sun

    Team•

    May 31, 2024

    @Vishnu Vankayala Hi Vishnu, could you share more in detail about how you envision this to work? We would like to understand how you want the user experience to be like so that we can improve the feature for you.

    • Vishnu Vankayala

      •

      May 31, 2024

      Hi Vera, whenever someone shares their email in the chat, we would want to capture that and trigger javascript for tracking purposes.

      • Luke Tan

        Team•

        Jun 4, 2024

        Hi @Vishnu Vankayala are you referring to when a user shares their email via our lead collection feature? Would you be looking for some kind of webhook that would trigger when Wonderchat collects a lead?

        • Vishnu Vankayala

          •

          Jun 4, 2024

          Webhook would be nice, but client side call back would be preferred for conversion tracking. Without the proper GCLIDS, FBCLIDS the attribution will be an issue. So call back would be good.

          • Luke Tan

            Team•

            Jun 11, 2024

            Hi Vishnu, we have just added support for this! Our widget will now fire an event whenever an email, phonenumber, or name is collected. You can listen for this event and execute your own javascript on your host page. Here is a sample piece of code you can use on your page to listen for events that the wonderchat widget will fire:

            window.addEventListener("message", function (e) {
              const parsed = JSON.parse(e.data);
              const { type, payload } = parsed;
            
              if (type === "wonderchat_field_collected") {
                const { field, value } = payload;
                console.log(payload) // View payload for debugging
                if (field === "EMAIL") {
                  // do something with value, e.g. test@example.com
                }
              }
            });

            In this case, field refers to the type of field that was collected, and value refers to the collected value. field can take one of three values, EMAIL , PHONE_NUMBER or NAME

            • Anonymous User

              •

              Jun 11, 2024

              Brilliant.. Appreciate it :)