Embedding Reference
Track visitors on your website by embedding a simple script. You can gather analytics about your audience, even if they don't click the shortened link.
How it works
The embed script runs on your website and sends a ping to viso.li servers. This ping is associated with a specific link slug and your account via a public key. This allows viso.li to record visits to your page as if they were clicks on the shortened link, providing you with unified analytics.
Usage
You can include the script simply in your HTML or depending on your framework, use the appropriate component for example Next.js Script component.
Configuration
The script requires the following data attributes:
data-slug: The slug of the shortened link you want to associate with this page.data-public-key: Your public embed key. This starts withpk_embed_. You can find this in your dashboard when generating an embed code.data-target: The base URL of the service (e.g.,https://viso.li).
Security & Constraints
To prevent abuse and ensure accurate analytics, the embed script includes security checks.
Hostname Validation
Origin or Referrer headers. The embed script makes a Cross-Origin request (CORS) to viso.li. Ensure your website allows these headers to be sent (e.g. check your Referrer-Policy).Public Key Safety
pk_embed_...) is designed to be public. It is safe to include it in your frontend code. However, do not use your secret API keys (sk_api_...) for embedding.Privacy Considerations
When using the embed script, you are collecting data about your visitors. Depending on your jurisdiction (e.g., GDPR in Europe, CCPA in California), you may be required to disclose this in your privacy policy.
We recommend informing your users that you use third-party analytics to improve their experience.