Overview
Tagging your website is easy with the Freestar React component.
Prerequisite
The below code snippets are examples. If you haven't downloaded your domain's tags.txt file or implemented the Freestar component, please do that first. Instructions are found here.
Basic usage
Use the following to render an ad with the Freestar component.
JSX
<FreestarAdSlot
publisher={'yourdomain-com'}
placementName={'yourdomaincom-placementName'}
/>
Â
Ensure you replace yourdomain-com and yourdomaincom-placementName with the variables from your React tags file.
Props
| Name | Scope | Description | Example | Type |
|---|---|---|---|---|
publisher |
Required | Publisher name - Provided by Freestar, found in your React tags file | 'yourdomain-com' |
String |
placementName |
Required | Ad unit placement name - Provided by Freestar, found in your React tags file | 'yourdomaincom-placementName |
String |
slotId |
Optional | Element ID of the containing div around the ad slot. Defaults to the placement | 'header-div' |
String |
targeting |
Optional | Key-value pairs for slot-specific targeting | { key1: 'value1', key2: 'value2' } |
Object |
channel |
Optional | Custom channel name | 'custom_channel' |
String |
classList |
Optional | Additional class names that should be applied to the wrapper DOM element of the ad slot | ['m-30', 'p-15', 'b-thin-red'] |
Array |
adRefresh |
Optional | Number bound to the ad refresh. Increment this value to trigger a refresh of the ad slot. | Â | Number |
onNewAdSlotsHook |
Optional | Event hook that returns the placementName when the component mounts and an ad is requested |
function newAdSlotCreated(placementName) { console.log('creating ad', placementName)} |
Function |
onDeleteAdSlotsHook |
Optional | Event hook that returns the placementName when the component unmounts |
function deletedAdSlot(placementName) { console.log('deleting ad', placementName)} |
Function |
onAdRefreshHook |
Optional | Event hook that returns the placementName when the component refreshes an ad |
function refreshedAd(placementName) { console.log('refreshing ad', placementName)} |
Function |
What's Next