CrossTalk Polls JavaScript Documentation

This documentation helps you add Polls to your webpage with CrossTalk's JavaScript SDK.


Import the SDK

Add the below script tag to your HTML file. You can add this either in the <head> or <body> section of your HTML file.

<script src="https://unpkg.com/crosstalk-comments-js"></script>

Add the CrossTalk div where you want to display the Polls

You can add style and class to this div to customise its positioning, margins within your webpage. The inner content won't be affected by your CSS

<div data-crosstalk-poll data-poll-id="your-poll-ID" data-wp="your-webproperty-name" data-url="URL" data-theme="light"></div>

List of params for CrossTalk Comments:

Variable Name Definition Expected Values
data-wp Your unique WebProperty Name. You can create Web Properties from the Dashboard Example: 'crosstalkDemo'. String value expected
data-poll-id Put the Poll ID (UUID) that you want to embed UUID (as string) value expected
data-url If you've created a Poll Rule on CrossTalk Dashboard to show a specific poll depending on the URL regex, provide the URL param `${window.location.origin}${window.location.pathname}`
data-page-id If you've created a Poll Rule on CrossTalk Dashboard to show a specific poll depending on the pageID, provide the pageID param PageID like 'sports_news'. String expected
data-theme Whether to load the widget in Light mode or Dark. If your website supports dynamic themes, pass this variable onto the widget so it blends right in Either light or dark. String value expected

Add the below code to your webpage for working CrossTalk Comments:

<script src="https://unpkg.com/crosstalk-comments-js"></script>
<div data-crosstalk-poll data-wp="crosstalkDemo" data-poll-id="5c810b75-41ad-456b-bdf7-820db342030c" data-theme="dark"></div>