Developer information for the poll unit

The documents in this category are intended for our media partners' developers. They assume knowledge of JavaScript and CSS.

Articles

Overview
The poll unit is a snippet of code downloaded from the InsightStore and placed in your website's HTML. The best placement is embedded directly into article content; however, other popular placements include below an article, in section pages, or the...
Integration
Note:  Whenever you see "civsci-id-123456789" , it must be replaced with your div identifier. Also, wherever we use a "000" value for a data-civicscience-widget attribute, that must be replaced with your poll unit target identifier, e...
Advanced integration
Advanced The basic integration code is suitable for most websites. This section describes a more advanced integration method. Container Element and Placement The best placement for the poll unit is embedded in an article's content. Other po...
Poll unit JavaScript function
The poll unit JavaScript function is called to load the instance into the container. The function accepts one argument: an object providing the poll unit settings. Here is a basic example: civicscience.widget({ target: "000", container: "#ci...
Poll unit customization
Detailed user research has been conducted to create a poll unit experience that will delight respondents and encourage them to answer questions. Thus, some aspects of the poll unit cannot be adjusted. This section discusses some parts of the poll ...
Forward compatibility warning
We are always improving the poll unit and developing new features and capabilities. To quickly make those features available, we may change the poll unit's HTML structure at any time and without notice. The customization settings described in thi...
Identifying respondents
We use several methods for identifying and remembering respondents and combining each respondent's answers from multiple poll unit visits into one profile. Cookies Our most common identification mechanism is a cookie placed by the poll unit. Aft...
Performance
Asynchronous JavaScript The async attribute on the poll unit integration code element instructs the browser to load the poll unit JavaScript library asynchronously without pausing the rendering of the page while the script is downloaded. ...
A/B testing
To improve the poll unit, we will occasionally conduct A/B tests for various characteristics. Whether an individual is in the A or B groups for the test depends on his or her respondent cookie identifier. Thus, the same user with the same computer...
Poll unit JavaScript events
(Updated 05/26/2022) The poll unit triggers custom events during its lifecycle. Your code may listen to these events and perform custom actions when the events occur. Example actions include logging to an analytics platform, modifying the page's ...
Third-party libraries used by the poll unit
The poll unit uses these third-party libraries: classlist element-matches-polyfill es6-object-assign fetch-jsonp intersection-observer micro-i18n nodelist-foreach-polyfill normalize.csspolyfill-array-includes preact promise-polyfill pr...