Skip to content

Instantly share code, notes, and snippets.

View Kugelschieber's full-sized avatar
💭
Working on Pirsch

Marvin Blum Kugelschieber

💭
Working on Pirsch
View GitHub Profile
@Kugelschieber
Kugelschieber / sample.js
Created October 18, 2024 10:45
Pirsch Funnel Visualization Example (ChartJS)
// Incomplete ChartJS demo code.
import {Chart} from "chart.js";
import {
BarController,
BarElement,
CategoryScale,
Chart,
Filler,
LinearScale,
@Kugelschieber
Kugelschieber / script.js
Last active August 13, 2024 11:24
Pirsch Custom Event Form Submission
<script>
function findFormTitle(node) {
const tag = node.tagName;
if (tag === "H1" || tag === "H2" || tag === "H3" || tag === "H4") {
return node.innerText;
}
for (const child of node.children) {
@Kugelschieber
Kugelschieber / links-with-keywords.html
Created March 7, 2024 11:01
Tracking links with specific keywords in the URL.
@Kugelschieber
Kugelschieber / internal-links.js
Last active February 7, 2024 10:27
Tracking internal links using custom events
@Kugelschieber
Kugelschieber / index.html
Last active December 2, 2023 17:10
Pirsch Vimeo Video Tracking Demo
<!DOCTYPE html>
<html>
<head>
<title>Vimeo Pirsch Demo</title>
<!-- Add the Pirsch extended script to support page views and events. -->
<script defer src="https://api.pirsch.io/pirsch-extended.js"
id="pirschextendedjs"
data-code="YOUR_PIRSCH_CODE"></script>
@Kugelschieber
Kugelschieber / index.html
Last active December 2, 2023 17:10
Pirsch YouTube Video Tracking Demo
<!DOCTYPE html>
<html>
<head>
<title>YouTube Pirsch Demo</title>
<!-- Add the Pirsch extended script to support page views and events. -->
<script defer src="https://api.pirsch.io/pirsch-extended.js"
id="pirschextendedjs"
data-code="YOUR_PIRSCH_CODE"></script>
@Kugelschieber
Kugelschieber / code.gs
Created May 12, 2023 13:04
Pirsch Analytics Google Sheets API Integration
const PIRSCH_CLIENT_ID = ScriptProperties.getProperty('client_id');
const PIRSCH_CLIENT_SECRET = ScriptProperties.getProperty('client_secret');
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu("Pirsch Analytics")
.addItem('Get Visitors', 'pasteVisitorsToSheet')
.addToUi();
}
@Kugelschieber
Kugelschieber / index.html
Created April 19, 2023 09:55
Track scroll position on an article using Pirsch Analytics
<!DOCTYPE html>
<html>
<head>
<title>Reading Percentage Demo</title>
<style type="text/css">
body {
max-width: 800px;
padding: 40px;
margin: 0 auto;
font-family: sans-serif;
@Kugelschieber
Kugelschieber / pirsch-event-cookie.js
Created February 25, 2023 00:36
Send an event once to Pirsch
@Kugelschieber
Kugelschieber / pirsch-api.md
Last active April 12, 2024 11:58
Sending a Page View to Pirsch Using the API

Getting an Access Token

This step is only required if you use a client ID + secret. A single access key allows you to skip the step, but it cannot be used to read statistics as with the other method. For write-only clients, we recommend using an access key.

Replace the CLIENT_ID and CLIENT_SECRET in the body. The access token in the response will be valid for 15 minutes.

curl --location --request POST 'https://api.pirsch.io/api/v1/token' \
--header 'Content-Type: application/json' \
--data-raw '{