From 32dd1335a5f87145ab9d67cbd6d70ba84975c27a Mon Sep 17 00:00:00 2001 From: Felix Scholze Date: Fri, 17 May 2024 00:01:59 +0200 Subject: [PATCH] feat: add crossorigin support --- README.md | 1 + src/matomo.ts | 2 ++ 2 files changed, 3 insertions(+) diff --git a/README.md b/README.md index aa022d3..2bdac72 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,7 @@ yarn add astro-matomo | `srcUrl?` | `string` | Defaults to matomo.js | | `debug?` | `boolean` | Activate debug mode | | `partytown?` | `boolean` | Adds [Partytown](https://partytown.builder.io/) support. Matomo added as: `` | +| `crossOrigin?` | `string` | Set `crossorigin` attribute | ## Example usage diff --git a/src/matomo.ts b/src/matomo.ts index 3792526..b928463 100644 --- a/src/matomo.ts +++ b/src/matomo.ts @@ -36,6 +36,8 @@ export function initMatomo(options: MatomoOptions): void { g = d.createElement("script"), s = d.getElementsByTagName("script")[0]; + if (options?.crossOrigin) g.crossOrigin = options.crossOrigin; + g.id = "matomo-script"; g.type = `text/${options?.partytown ? "partytown" : "javascript"}`; g.async = true;