Skip to content

Commit

Permalink
Merge pull request #12 from dserv-nh/custom-script-url
Browse files Browse the repository at this point in the history
feat: support custom script host and name
  • Loading branch information
iskrisis authored Mar 25, 2024
2 parents 09dc79e + fb8d6c5 commit c3d1265
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 6 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,15 @@ or download from releases

There is also `floriankarsten.plausible.domain` which allows you to overwrite `data-domain` in the frontend snippet.

config.php example
`config.php` example
```php
'floriankarsten.plausible' => [
'sharedLink' => 'https://plausible.io/share/yourwebsiteurl.com?auth=Jz0mCWTPu5opXi0sAgRrq',
'domain' => 'test.com' // not required if not set it will be taken from $site->url
'domain' => 'test.com', // not required if not set it will be taken from $site->url
// To use a self-hosted Plausible instance
//'scriptHost' => 'https://plausible.example.com',
// To use Plausible script extensions
//'scriptName' => 'plausible.outbound-links.exclusions'
];
```

Expand Down
2 changes: 1 addition & 1 deletion snippets/plausible.php
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<?php if(option('debug') !== true && !kirby()->user()): ?>
<script defer data-domain="<?= option('floriankarsten.plausible.domain') ?? parse_url($kirby->url('index'))['host'] ?>" src="https://plausible.io/js/plausible.js"></script>
<script defer data-domain="<?= option('floriankarsten.plausible.domain') ?? parse_url($kirby->url('index'))['host'] ?>" src="<?= option('floriankarsten.plausible.scriptHost') ?? 'https://plausible.io' ?>/js/<?= option('floriankarsten.plausible.scriptName') ?? 'plausible' ?>.js"></script>
<?php endif; ?>

0 comments on commit c3d1265

Please sign in to comment.