Version 1.0.0
This commit is contained in:
25
resources/js/components/analytics.tsx
Normal file
25
resources/js/components/analytics.tsx
Normal file
@@ -0,0 +1,25 @@
|
||||
import { useEffect } from 'react';
|
||||
|
||||
interface AnalyticsProps {
|
||||
url?: string;
|
||||
websiteId?: string;
|
||||
}
|
||||
|
||||
export default function Analytics({ url, websiteId }: AnalyticsProps) {
|
||||
useEffect(() => {
|
||||
if (!url || !websiteId) return;
|
||||
|
||||
const script = document.createElement('script');
|
||||
script.src = url;
|
||||
script.defer = true;
|
||||
script.setAttribute('data-website-id', websiteId);
|
||||
|
||||
document.head.appendChild(script);
|
||||
|
||||
return () => {
|
||||
document.head.removeChild(script);
|
||||
};
|
||||
}, [url, websiteId]);
|
||||
|
||||
return null;
|
||||
}
|
||||
Reference in New Issue
Block a user