umami/components/forms/TrackingCodeForm.js

24 lines
710 B
JavaScript
Raw Normal View History

2022-08-08 20:50:27 +02:00
import useConfig from 'hooks/useConfig';
import { useRef } from 'react';
import { Form, FormRow, TextArea } from 'react-basics';
2020-08-08 05:36:57 +02:00
export default function TrackingCodeForm({ websiteId }) {
const ref = useRef(null);
2022-08-08 20:50:27 +02:00
const { trackerScriptName } = useConfig();
const code = `<script async defer src="${trackerScriptName}" data-website-id="${websiteId}"></script>`;
2020-08-08 05:36:57 +02:00
return (
<>
<Form ref={ref}>
<FormRow>
<p>
To track stats for this website, place the following code in the{' '}
<code>&lt;head&gt;</code> section of your HTML.
</p>
<TextArea rows={4} value={code} readOnly allowCopy />
</FormRow>
</Form>
</>
2020-08-08 05:36:57 +02:00
);
}