Code Monkey home page Code Monkey logo

react-outbrain-widget's Introduction

react-outbrain-widget

Embed your outbrain widget inside a react app

npm version

Demo

Live Demo

Installation

Note: react-outbrain-widget assumes outbrain.js was loaded before react's first rendering. Please make sure outbrain.js is loaded via a script tag on the app's index.html

<head>
	<script async src="https://widgets.outbrain.com/outbrain.js"></script>
</head>

With NPM

npm install react-outbrain-widget --save

Usage

Include the Component

import React from 'react';
import { OutbrainWidget } from 'react-outbrain-widget';

class Component extends React.Component {
  render() {
    return (
      <OutbrainWidget dataSrc="mySite.com" dataWidgetId="AR_1" />
    );
  }
}

Placement props (Only use advised one)

Either of the following props is required to use the component. Use the correct props and value which were advised by your Sales Engineer to represent where the widget is served.

Props Name Type Integration type Description Example
dataSrc String Direct Web The crawlable URL of the current page "http://www.webx0.com/2010/07/some-posthype-thoughts-about-flipboard.html"
obContentUrl String Web Mediation The crawlable URL of the placement "http://www.webx0.com/2010/07/some-posthype-thoughts-about-flipboard.html"
obBundleUrl String App The store URL of the App "https://play.google.com/store/apps/details?id=com.outbrain.app"
obPortalUrl String Native Environment A URL representing the context where the ad placement is presented to users. Does not need to be a reachable/crawlable URL. "http://www.chatPortal.com"

Other props

props Name Type Requirement Description Example
dataWidgetId String Required  The widget ID as provided by Outbrain. "JS_1"
obInstallationKey String Required for Web Mediation, App and Native Environment  Installation/partner key as provided by Outbrain. "ABC1234567890"
obUserId String Required for App & Native Environment  It is mandatory to pass the Google or Apple Advertising ID for Outbrain installations in mobile apps, according to Google and Apple guidelines and developer agreements. See this page for Outbrain requirements. "EA7583CD-A667-48BC-B806-42ECB2B48606"
obLanguage String Required for App & Native Environment  The 2-letter language code (ISO-639-1-alpha-2). Must be added if bundleUrl or portalUrl is sent. "en"
data-ob-app-id String Required for pre-installed App Environment The App's unique identifier iOS: Bundle ID, Android: Application ID/Package Name "com.outbrain.app"
data-app-ver String Optional A version number of the App "1.0.0"
obPsub String Only if instructed by SE, App & Native only  String value for additional section-level reporting breakdowns. Allowed characters: alphanumeric and underscore '_'. Requires permission from your Sales Engineer or Partner Manager. "minus1"
externalId String Optional String value with maximum of 70 characters for use with the Engage Variant Reporting API. A maximum of 10K IDs/hour are supported. Contact your Partner Manager for API access. "id123"

Rendering optimisation

Modifications not recommended

The component itself handles rendering of widgets when required props are given properly. When it doesn't work as expected on your site, please do not try modifying the code of component itself, but contact your Sales Engineer or Partner manager with sample pages.

The component must not be hidden or cached.

If the page history is cached in the DOM tree, please remove the component itself from the cache. Only the component placed in the visible contents should be rendered. Toggle example:

render() {
  return (
      {showOutbrainWidget ? <OutbrainWidget dataSrc="mySite.com" dataWidgetId="AR_1" /> : null}
  );
}

Server Side Rendering

The component should work with SSR. If it's used in the combination of SSR and CSR, it should either reuse the components (rehydration) or clear them (clear the Placement prop) and make sure to remove the component on hidden contents as mentioned in the previous section.

react-outbrain-widget's People

Contributors

tomerlevy1 avatar amirgro avatar dependabot[bot] avatar obaglazer avatar sotagu avatar monska85 avatar philipheinser avatar urielster avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.