Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get access to HTML head for Analytics #1164

Closed
shaoormunir opened this issue Jul 25, 2024 · 1 comment
Closed

Get access to HTML head for Analytics #1164

shaoormunir opened this issue Jul 25, 2024 · 1 comment

Comments

@shaoormunir
Copy link

Is there a way to access the <head> section of the Chainlit frontend without using a completely custom front end to integrate Google Analytics and other analytic services?

@ahmadmayahi
Copy link

Create a custom js file /public/app.js.

Modify config config.toml:

custom_js = "/public/app.js"

Add this into app.js:

const script = document.createElement('script');
script.src = 'https://plausible.io/js/script.js'; // URL of the remote file
script.onload = () => {
  console.log('Remote script loaded successfully.');
};
script.onerror = () => {
  console.error('Error loading remote script.');
};
document.head.appendChild(script);

I use it for plausible here, but you can use it any other platform.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants