Loading Yotpo Reviews with AJAX
    • Dark
      Light

    Loading Yotpo Reviews with AJAX

    • Dark
      Light

    Article summary

    Products


    Reviews
    Supported plans

    Free, Starter, Pro, Premium, Enterprise

    eCommerce Platform

    N/A

    Yotpo's on-site assets and features load asynchronously. This means that the various widgets will only be loaded once on the initial page load, and will be then ignored by any AJAX scripts running on the page. As such, AJAX-based elements such as endless scroll pages or custom product pages will only appear on the initial page load. 

    In this article, you'll learn how to load Yotpo Reviews with AJAX.

    Please note:
    Due to advanced requirements, these codes should only be added by an experienced developer.

    Loading Yotpo with AJAX

    To properly display Yotpo on-site assets on pages that dynamically update content (without reloading the entire page), it is necessary to reinitialize Yotpo assets every time new content is loaded.

    To automatically update and re-initiate Yotpo assets, the Javascript below must be added to callback functions when new content is loaded.

    For new widgets:

    yotpoWidgetsContainer.initWidgets()

    For legacy widgets:

    Please note:
    The Yotpo JavaScript library needs to be loaded at this point
    yotpo.initWidgets()

    In addition to updating the callback functions, be sure to update the relevant widget attributes per product:

    For example:

    • Product ID
    • Product URL
    • Product Name
    • Product Description

    Upon refreshing the page content, on-site assets will be updated to reflect the correct data attributes.



    Was this article helpful?