New SectionURL NameHow-to-Integrate-TargetBay-Reviews-on-a-Custom-WebsiteTitleHow to Integrate TargetBay Reviews on a Custom WebsiteOwnerGayatriArticle DetailsContentHelp ContentThis guide provides the complete steps to manually install TargetBay Reviews on a custom website. This process involves syncing your product and order data via API and then placing the main script and individual widget tags on your site. 🛠️ Prerequisites Before installing the review widgets, you must ensure your category, product and order data are being synced with TargetBay. This is a crucial step that allows our platform to associate reviews with the correct products and customers. This data sync is performed using the TargetBay API. 1. Generate API Credentials & Set Review Scopes To connect your custom website, you must generate a Client ID, a Client Secret, and define the API Scope.Important: For review integration, you must specifically enable the Review scope in your BayEngage account to authorize API calls. Step 1: Log in to BayEngage and navigate to Apps → Custom Integration Settings. Step 2: After clicking Settings, navigate to Version 2.0 and click the Create button. Step 3: When the "Create Scope" modal appears, scroll down to the Review section. Step 4: Check the boxes for read (to fetch review data) and write (if you intend to submit reviews via API). Step 5: Click Create to generate your token. For a complete, step-by-step guide on generating and using these credentials, please follow the instructions in our detailed article: How to Generate Client ID, Client Secret, and Scope for V2 API Access 2. Access API Documentation For fetching product review lists, aggregate ratings, and moderating content, refer to our technical documentation: Official Review API Reference: TargetBay Review API Docs Required Authorization: These endpoints require a bearer token with the read_review and write_review scope. Step 1: Install the Main TargetBay Script This main script must be placed once on every page where you intend to display a TargetBay widget. The recommended best practice is to place it in the global <head> section of your website's template to ensure it loads on all pages. Step-by-Step Installation Open your website's main HTML template or layout file. This is the file that contains the global <head> tag. Paste the main TargetBay script provided below just before the closing </head> tag. Important: Replace the placeholder values (e.g., YOUR_STORE_DOMAIN, CURRENT_PRODUCT_ID) with the corresponding dynamic variables from your website platform. For example, if your site URL is https://my-sample-shop-name.mystore.com, your store domain should be my-sample-shop-name.mystore.com. Note: Do not include https://—adding it will prevent the setup from working correctly. <script type="text/javascript"> (function() { window.brv = window.brv || {}; window.brv.commonData = { storeDomain: 'YOUR_STORE_DOMAIN', productId: 'CURRENT_PRODUCT_ID', userId: 'CURRENT_USER_ID', userName: 'CURRENT_USER_NAME', userEmail: 'CURRENT_USER_EMAIL', }; })(); (function() { var script = document.createElement('script'); script.src = 'https://sf-rv.bayengage.com/d/tbr-bundle.min.js';; script.type = 'text/javascript'; script.async = true; document.head.appendChild(script); })(); </script> Save and deploy the updated file. Why place it in the <head>?Placing the script in the <head> ensures it loads before the rest of the page content. This allows the subsequent widget tags (<div> elements) to be recognized and populated correctly when the page renders. Step 2: Place TargetBay Widget Tags Once the main script is installed, you can place the specific widget tags (HTML <div> elements) anywhere on your site where you want a review component to appear. Placement Guide Identify the page and location for the widget. Copy the corresponding HTML widget tag from the list below. These tags are simple <div> elements that the main script recognizes. Product Reviews Container:<div id="_tbr_pdr"></div> Product Statistics Container (Aggregate Star Rating): <div id="_tbr_stat"></div> Product Q&A Container:<div id="_tbr_qna"></div> Business Reviews Container:<div id="_tbr_bus"></div> Paste the widget tag into your HTML code at the desired location. Save and deploy the updated files. Collection page Reviews Container:<div id="_tbr_col_stat" data-rating="CURRENT_PRODUCT_RATING" data-review-count="CURRENT_PRODUCT_COUNT"> </div> CURRENT_PRODUCT_RATING: Replace this value with the dynamic product rating. CURRENT_PRODUCT_COUNT: Replace this value with the dynamic product review count. Exposing the product review information in the product API Check the API details: Product API. We are sharing the review count and review aggregate rating. The get all product API has these information at product level - review_count and review_rating Using this API a daily job needs to be executed to pull the review information and update it against the product meta at client’s end. The dynamic reference of this data that is stored needs to be replaced in the above placeholder mentioned. 📝 Important Technical Notes Scope Access: If your API calls return a 403 Forbidden error, verify that the Review scope (read/write) was correctly selected during the credential generation process in BayEngage. Daily Sync: We recommend running a daily job to pull review_count and review_rating from the Product API to update your local product meta-data for faster page rendering. Product ID Match: The productId passed in the Step 1 script must exactly match the ID sent in your product data feed. If these don't match, the widgets will remain empty. Load Order: The Main Script in the <head> must always execute before the widget <div> tags in the <body>. With the technical installation complete, you can now configure your widgets, set up automations, and manage reviews in the TargetBay admin app. Learn how in our detailed guide: Getting Started with the TargetBay Reviews Admin App: A Complete Guide