Skip to content

Instantly share code, notes, and snippets.

View vanaf1979's full-sized avatar

VA79 vanaf1979

View GitHub Profile
@vanaf1979
vanaf1979 / ga4-ajax-form-submittion.js
Created February 8, 2026 12:34
GA4 ajax form submittion
const form = document.getElementById('contact-form');
form.addEventListener('submit', function(e) {
// Your existing form logic here...
gtag('event', 'generate_lead', {
'event_category': 'Contact',
'event_label': 'Main Contact Form',
'value': 1.0 // Optional: assign a lead value
@vanaf1979
vanaf1979 / ga4-custom-page-views.js
Created February 8, 2026 12:33
GA4 custom page views
gtag('event', 'page_view', {
page_title: document.title,
page_location: window.location.href,
page_path: window.location.pathname
});
@vanaf1979
vanaf1979 / ga4-disable-page-view.js
Created February 8, 2026 12:32
GA4 disable page view
gtag('config', 'G-XXXXXXXXXX', {
send_page_view: false
});
<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-XXXXXXXXXX');
</script>
@vanaf1979
vanaf1979 / gmip-cf.php
Last active March 6, 2024 09:41
Wordpress shortcode and tags/functions to deal with cloudflare returned country codes
<?php
/**
* GMIP
*
* @package GMIP
* @author Stephan Nijman
* @copyright 2024 Granmedia
* @license GPL-2.0-or-later
* @version 1.0.0
*
<!doctype html>
<html lang="en">
<head>
<!-- This is your document head.-->
<!-- It is not visible to the user, but it contains information for the browser,-->
<!-- like the title, seo meta tags and stylesheet links.-->
<!-- Docs; https://developer.mozilla.org/en-US/docs/Web/HTML/Element/head -->
<title>Document</title>
</head>
<body>
// Name: shoes
import "@johnlindquist/kit";
let Jimp = await npm("jimp")
let text = await editor(`
## Enter a url per line
## Hit cmd+s to "continue"
@vanaf1979
vanaf1979 / RenderedBlocks.php
Created March 24, 2021 08:29
Are blocks rendered yet
<?php
final class RenderedBlocks {
/**
* instance.
*
* @var RenderedBlocks $instance class instance.
*/
private static $instance = null;
<div class="box"></div>
<button id="addClass">Add active class</button>
<button id="removeClass">Remove active class</button>
<button id="toggleClass">Toggle active class</button>
<div class="box"></div>
<button id="addClass">Add active class</button>
<button id="removeClass">Remove active class</button>