Javascript API Methods

Fetch reviews

See List Reviews

List all reviews

Fetch all reviews, including store reviews and product reviews.

fera.getReviews((reviews) => {
  reviews.forEach((review) => {
    if (review.product) {
        console.log(`${ review.customer.display_name } rated ${ review.product.name } ${ review.rating }/5.`);
    } else {
        console.log(`${ review.customer.display_name } rated the store ${ review.rating }/5.`);
    }
  });
});

List reviews for a specific product

List only reviews about a specific product.

fera.getReviews('PRODUCT_ID', (reviews) => {
  reviews.forEach((review) => {
    console.log(`${ review.customer.display_name } rated the product ${ review.rating }/5.`);
  });
});

Fetch ratings

See List ratings

Retrieve product rating

fera.getRating('PRODUCT_ID', (rating) => {
    console.log(`That product is rated ${ rating.average }/5 and has ${ rating.count } reviews`);
});

List multiple product ratings

fera.getRatings(['PRODUCT_ID1', 'PRODUCT_ID2'], (ratings) => {
  ratings.forEach((rating) => {
    console.log(`Product with ID ${ rating.external_product_id } is rated ${ rating.average }/5 and has ${ rating.count } reviews`);
  });
});

Retrieve store's overall rating

fera.getRating((rating) => {
    console.log(`This store's rated ${ rating.average }/5 and has ${ rating.count } reviews`);
});

Fetch photos & videos (media)

List all photos & videos

fera.getMedia((media) => {
  media.forEach((m) => {
    console.log(`${ m.customer.display_name } submitted ${ m.type }: ${ m.url }.`);
  });
});

List photos and videos for a specific product

fera.getMedia('PRODUCT_ID', (media) => {
  media.forEach((m) => {
    console.log(`${ m.customer.display_name } submitted ${ m.type }: ${ m.url }.`);
  });
});

Show submission modal

Show the review/photo/video submission modal.

fera.showContentSubmitter();

Push conversion event

Let Fera know that a purchase (AKA order) has occurred. This will trigger scheduling of review requests in the future.

fera.push('order', { // FYI fera.push('pushOrder' also works, this is just more readable
  id:            "12345",
  line_items: [{
    name:         "Product 123",
    product_id:   "product-123",
    variant_id:   "variation1", // If variant exists
    total:        100.0
  }],
  customer_id:   "customer-123"
});

Set current state

Set current product

fera.push('setProduct', {
  "id":                   "product-123", // String
  "name":                 "Product 123", // String
  "price":                99.89, // (Optional) Float
  "url":                  "https://www.example.com/products/product-123", // String
  "thumbnail_url":        "https://cdn.example.com/products/product-123/image.png" // String
});

👍

As long as you installed one of our site platform apps (like our Shopify App, Wix App or BigCommerce App) then this is done automatically for you.

Set current customer

Tells Fera who the current customer that is browsing the site is so they can be prefilled into the customer review submission modal (if they didn't click on a review request link).

fera.setCustomer({ 
  name: "Tobias Funke", 
  email: "[email protected]",
  customer_id: "customer-123",
  name: "John Doe",
  email: "[email protected]",
  country_code: "US",
  region_name: "California",
  city_name: "Orange County",
  zip: "78730"
});

👍

If customers submit reviews from a review request link (like in an email) then this is done automatically for you (and more securely).

Listen to events

Use the on() method to listen to client-side events like this:

fera.on('submitter.show', (submitter) => console.log("Content submission modal was just shown."));

See Javascript API Events for a list of events you can listen for.