Analytics & Reports
Analytics

Top-level Configuration

Property Type Default Required
customerId string Yes
area string DEFAULT_AREA
collection ValueOptions<T> DEFAULT_COLLECTION
collections { overrides: object | function }
details { overrides: object | function }
refinements { overrides: object | function }
bootstrap function
history object DEFAULT_HISTORY

customerId

Your customer ID, e.g. --customerId--.

area

The area you wish to fire against, production, staging, etc. If not specified, the Production area will be used (and if one doesn’t exist, an error will be returned).

collection

The product collection to use. If you don’t pass this parameter, it will default to default. This is case sensitive and should be same as your collection name.

For example:

collection: {
  options: ['faq', 'articles', 'mainProducts'],
  default: 'mainProducts',
}

The above configuration will search by default against the collection configured in default, and allow the user to switch into the other collection which will appear as an alternative option.

The collection switching is rendered by the <gb-collections> tag and the labels for the above collections are configured in tags under collections.

collections

The overrides to use for your collection count call to the search API. Please refer to SEARCH API for what parameters you can pass in here.

For example, we can override the area used:

collections: {
  overrides: {
    area: 'Production'
  }
}

You can also use a function that returns an object to set the overrides:

collections: {
  overrides: (currReq, prevReq) => {
    // do stuff
    return { ...currReq, area: 'Production' };
  }
}

details

The overrides to use for your details calls to the search API. Please refer to SEARCH API for what parameters you can pass in here.

For example, we can override the collection used:

details: {
  overrides: {
    collection: 'Main'
  }
}

You can also use a function that returns an object to set the overrides:

details: {
  overrides: (currReq, prevReq) => {
    // do stuff
    return { ...currReq, collection: 'Main' };
  }
}

refinements

The overrides to use for your more refinements calls to the refinements search API. Please refer to SEARCH API for what parameters you can pass in here. These overrides will be applied to the originalQuery object sent with the refinements call.

Omit this override

If a refinement override is not provided or is an empty object, the search override will be used for these calls. In almost all cases, you will want to omit this override to allow the search override to be applied.

For example, we can override the originalQuery used:

refinements: {
  overrides: {
    query: 'dress'
  }
}

You can also use a function that returns an object to set the overrides:

refinements: {
  overrides: (currReq, prevReq) => {
    // do stuff
    return { ...currReq, query: 'dress' };
  }
}
Overriding the refinements call is potentially destructive

This override should only be used to better recreate the original search request that was made to get the current set of products. One potential use case is to avoid selecting a refinement that was already selected by your search override.

bootstrap

An optional function which will be invoked at StoreFront instantiation time.

The bootstrap function – which is invoked with the StoreFront instance – can be used to perform synchronous operations before the StoreFront application is mounted.

...
bootstrap: (app) => {
  // Ensure the `myCoolId` element is present in the DOM.
  const selector = 'myCoolId';

  if (!document.getElementById(selector)) {
    const elem = document.createElement('section');
    elem.id = selector;
    document.body.appendChild(elem);
  }
},
...
Asynchronous operations

Asynchronous operations such as setTimeout, setInterval, network requests, and so on may be used, although they will not resolve before instantiation is complete.

history

The history configuration can be used to remove portions of the application state before it is saved to browser history. Since select browsers – such as Firefox. Enforce a maximum byte size for each history entry, this may be useful for implementations which operate on products with many variants, or which make extensive use of template data.

To remove navigations, products, template data, and a subset of autocomplete data before saving the application state to browser history, set the length option to 0.

...
history: {
  length: 0,
},
...