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

Pirsch reading statistics example using the API

Step 0

Create a client ID and secret on the developer settings page and save the secret for later use.

Step 1

Get a temporary access token.

@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
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 / 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 / internal-links.js
Last active February 7, 2024 10:27
Tracking internal links using custom events
@Kugelschieber
Kugelschieber / links-with-keywords.html
Created March 7, 2024 11:01
Tracking links with specific keywords in the URL.
@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 '{