Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div class="sample-form">
  <p id="fetchMessage">Waiting for init...</p>

<form id="searchForm" class="sample-form sample-form--search">
  <input type="text" class="input-text" placeholder="Type something ( e.g. 'book') and hit enter" id="searchInput" disabled />
  <input type="submit" value="Search" id="submitSearch" disabled />

<br />
<p class="sample-form">Search results:</p>


                body {
  background: #eee;
* {
  box-sizing: border-box;
/* CSS Simple Pre Code */
pre {
  background: #333;
  white-space: pre;
  word-wrap: break-word;
  overflow: auto;
  margin: 20px 25px;
  border-radius: 4px;
  border: 1px solid #292929;
  position: relative;

  code {
    display: block;
    padding: 15px 16px 14px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 19px;
    color: #ddd;

.sample-form {
  display: flex;
  align-items: center;
  margin-left: 25px;

  input {
    height: 40px;

.input-text {
  width: 300px;



                import Fuse from "";

const elFetchMessage = document.querySelector("#fetchMessage");
const elSearchForm = document.querySelector("#searchForm");
const elSearchInput = document.querySelector("#searchInput");
const elCode = document.querySelector("code");

 * ======== CONFIG ========
 * Now filled with test data.
 * In your app you will have to adjust params with values that you will receive from us.

// Your ID in our system, you will receive it from us at the time of integration
const FEED_ID = '55aadd60-9d14-11eb-9cc8-0abff1de8e13';

// Domain address for which the integration is to work. For example,
// You have two domains, and On both, you assign DOMAIN_ADDRESS according to the domain in which it is used.
// Now in our platform traffic will be tracked separately for and
const DOMAIN_ADDRESS = 'autocomplete-demo';
/* ==================== */

/* Final URL to fetch brands*/

 * Used to handle fuse.js search algorithm
let fuseBrands;




 * Initialize app data
 * */
function initBrands() {
    elFetchMessage.innerText = "Fetching brands ...";

    return fetchBrands()
        .then((respBrands) => {
            elFetchMessage.innerText = `Brands(${respBrands.length}) fetched successfully!`;

            return respBrands;
        .then((respBrands) => {
             * We're using Fuse.js to handle search, but you can just assign brands
             * to some variable and filter it in 'getBrandsByQuery' in your own way
            fuseBrands = new Fuse(respBrands, {
                keys: ["", "brandData.url"],
                minMatchCharLength: 3,
                threshold: 0.05

            return respBrands;
        }).catch((e) => {
            elFetchMessage.innerText = "Something went wrong";

 * Fetch should be done once, after the page load. In response u get ads that u can filter by your search algorithm
 * response type:
 * {
 *   brands:[{
 *     brandData: {
 *       name: string,
 *       url: string
 *     },
 *     estimatedCpc: number,
 *     visitUrl: string,
 *   }]
 * }
function fetchBrands(feedId) {
    return fetch(BRANDS_SOURCE_URL)
        .then((resp) => resp.json())
        .then((data) => data.brands);

function handleSearchSubmit(e) {
    const query = elSearchInput.value;
    const ads = getBrandsByQuery(query);

    elCode.innerText = JSON.stringify(ads, null, 4);

     * You can use your own search algorithm, in this example we used fuse.js
    function getBrandsByQuery(query) {
        return, { limit: 4 }).map((result) => result.item);

 * Bellow are methods used only to format example page
function toggleDisabledSearch(state) {
    elSearchForm.querySelectorAll("input").forEach((input) => {
        input.disabled = state;

function initListeners() {
    elSearchForm.addEventListener("submit", handleSearchSubmit, false);