Skip to content

Instantly share code, notes, and snippets.

@justusbluemer
justusbluemer / gtagGeolocation.js
Last active March 14, 2024 12:52
gtagGeolocation
async function gtagGeolocation() {
try {
// Fetch the script from the specified URL
const response = await fetch('https://www.googletagmanager.com/gtag/js?id=G-CRGJ6H77X9&l=dataLayer&cx=c');
const text = await response.text();
// Use regex to extract the Base64 string
const regex = /=JSON\.parse\(zb\("(.+?)"\)\)/;
const matches = regex.exec(text);
@justusbluemer
justusbluemer / gtm-snippet-with-fallback.html
Created January 30, 2023 11:38
Google Tag Manager gtm.js 1st party snippet with www.googletagmanager.com fallback
<!-- Google Tag Manager -->
<script>
(function (w, d, s, l, i) {
w[l] = w[l] || [];
w[l].push({ "gtm.start": new Date().getTime(), event: "gtm.js" });
var f = d.getElementsByTagName(s)[0],
j = d.createElement(s),
dl = l != "dataLayer" ? "&l=" + l : "";
j.async = true;
j.onerror = function () {
const log = function() {
console.log("This was tracked to GA:")
console.log(arguments);
// … perhaps doing something else with this
}
google_tag_manager.mb.listen(log)
@justusbluemer
justusbluemer / adcell.js
Created February 2, 2021 15:51
ADCELL conversion tracking code
<script type="text/javascript" src="http://www.adcell.de/js/jsadlib.js"></script>
<script type="text/javascript">
Adcell.user.track({
'pid' : '0000',
'eventid' : '0000',
'referenz' : 'ABC_123',
'betrag' : '123.45'
});
</script>
function() {
var setCookie = function (cookieName, cookieValue, expirationInMinutes, domain) {
var expirationTime = expirationInMinutes * 60 * 1000;
var date = new Date();
var dateTimeNow = date.getTime();
date.setTime(dateTimeNow + expirationTime);
var expirationTime = date.toUTCString();
document.cookie = cookieName+"="+cookieValue+"; expires="+expirationTime+"; path=/; domain="+domain;
@justusbluemer
justusbluemer / loadJSONFiles.js
Created December 2, 2019 15:53
Loads files from a directory and parses them as JSON
const fs = require("fs")
;(async function() {
let items = await loadJSONFiles("items/")
console.log(items)
})()
/**
* Loads and parses JSON files from the specified directory
* @param {string} dirname The name of the directory
@justusbluemer
justusbluemer / couchdb-reset-password-macos.md
Last active July 16, 2019 08:18
How to reset the CouchDB admin password on macOS

If you want to reset the admin password of your CouchDB database, you just have to edit your configuration file at

/Users/{username}/Library/Preferences/couchdb2-local.ini

and remove the lines immediately after "[admins]". Then, restart CouchDB. Please make sure to create a new admin user for security.

Thanks to Alex Burghardt for his hint at apache/couchdb#1020 (comment)

import React, { Component } from 'react'
import { connect } from 'react-redux'
import { withRouter } from 'react-router-dom'
import classNames from 'classnames'
import styles from './Pager.styl'
import queryBuilder from './queryBuilder'
const Page = ({ page, currentPage, onClick }) => {
const diff = Math.abs(page.number - currentPage)
const className = classNames({
@justusbluemer
justusbluemer / gist:91629adc9ceca3323e983b7043b042eb
Created November 27, 2018 12:55
Link tracking example without data- attributes
<a href="/example" id="link-123">Anchor text</a>
<script>
var linkTrackingData = [
{
id: 'link-123',
dyn_eventaction: '…',
dyn_teasertype: '…',
moduletype: '…',
elementinfo: '…',