2023-01-10 08:59:26 +01:00
|
|
|
import { TextArea } from 'react-basics';
|
2023-03-22 22:05:55 +01:00
|
|
|
import useMessages from 'hooks/useMessages';
|
2023-04-20 16:41:25 +02:00
|
|
|
import useConfig from 'hooks/useConfig';
|
2023-01-10 08:59:26 +01:00
|
|
|
|
2023-04-21 17:00:42 +02:00
|
|
|
export function TrackingCode({ websiteId }) {
|
2023-03-22 22:05:55 +01:00
|
|
|
const { formatMessage, messages } = useMessages();
|
2023-04-20 16:41:25 +02:00
|
|
|
const { trackerScriptName } = useConfig();
|
|
|
|
const url = trackerScriptName.startsWith('http')
|
|
|
|
? trackerScriptName
|
|
|
|
: `${location.origin}/${trackerScriptName}.js`;
|
2023-01-10 09:13:32 +01:00
|
|
|
|
|
|
|
const code = `<script async src="${url}" data-website-id="${websiteId}"></script>`;
|
2023-01-10 08:59:26 +01:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
2023-01-25 16:42:46 +01:00
|
|
|
<p>{formatMessage(messages.trackingCode)}</p>
|
2023-01-10 08:59:26 +01:00
|
|
|
<TextArea rows={4} value={code} readOnly allowCopy />
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
2023-04-21 17:00:42 +02:00
|
|
|
|
|
|
|
export default TrackingCode;
|