umami/components/pages/settings/websites/TrackingCode.js

21 lines
610 B
JavaScript
Raw Normal View History

2023-01-10 08:59:26 +01:00
import { TextArea } from 'react-basics';
import { TRACKER_SCRIPT_URL } from 'lib/constants';
export default function TrackingCode({ websiteId }) {
2023-01-10 09:13:32 +01:00
const url = TRACKER_SCRIPT_URL.startsWith('http')
? TRACKER_SCRIPT_URL
: `${location.origin}${TRACKER_SCRIPT_URL}`;
const code = `<script async src="${url}" data-website-id="${websiteId}"></script>`;
2023-01-10 08:59:26 +01:00
return (
<>
<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 />
</>
);
}