import React, { useState } from 'react' import TextBox from '../components/TextBox' import NoticeBox from '../components/NoticeBox' import { CustomTagRules } from '../components/CustomTagRules' declare const ajaxurl: string declare const wcbe_nonce: string interface DataItem { name: string value: string } interface WPJSONResponse { data: string success: boolean } interface SettingsPageProps { data: DataItem[] | null } const SettingsPage: React.FC = ({ data }) => { const [inputValues, setInputValues] = useState( data ? data.reduce((acc, item) => { return { ...acc, ...item } }, {} as { [key: string]: string }) : {} ) const [showNotice, setShowNotice] = useState(false) const [noticeText, setNoticeText] = useState('') const [noticeClass, setNoticeClass] = useState('') const handleInputChange = ( event: React.ChangeEvent ) => { const name = event.target.name const newValue = event.target.value setInputValues((prevValues) => ({ ...prevValues, [name]: newValue })) } const handleCheckboxChange = (event: React.ChangeEvent) => { const name = event.target.name const newValue = event.target.checked ? '1' : '0' setInputValues((prevValues) => ({ ...prevValues, [name]: newValue })) } const handleCustomTagRulesChange = (rulesJson: string) => { setInputValues((prevValues) => ({ ...prevValues, edgetag_custom_tag_rules: rulesJson, })) } const handleNoticeClose = () => { setShowNotice(false) } const handleSave = async (e: React.MouseEvent) => { const target = e.target as HTMLButtonElement target.classList.add('loading') try { const formData = new URLSearchParams() formData.append('nonce', wcbe_nonce) formData.append('action', 'set_edgetag_options') formData.append('data', JSON.stringify(inputValues)) const response = await fetch(ajaxurl, { method: 'POST', body: formData, headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, }) if (!response.ok) { throw new Error( `Could not fetch - ${response.status}: ${ response.statusText }\n\n${await response.text()}` ) } const responseData = (await response.json()) as WPJSONResponse target.classList.remove('loading') setNoticeText(responseData.data) setNoticeClass('updated') } catch (err) { target.classList.remove('loading') setNoticeText((err as Error).message) setNoticeClass('error') } finally { setShowNotice(true) } } return (

Settings

You can find your URL in{' '} https://app.edgetag.io {' '} under tag details
We automatically try to capture newsletter forms, but if its still not working please add your own HTML selectors here.
By default we would be sending newsletter subscription as Lead event. If you want to change the event name, you can do it here.