Skip to content

Instantly share code, notes, and snippets.

View prabapro's full-sized avatar
🍃
Working from home

Praba Ponnambalam prabapro

🍃
Working from home
View GitHub Profile
@prabapro
prabapro / readme.md
Created September 1, 2020 16:33
GTMTips: Prevent Clicks And Form Submits From Redirecting - Bookmarklet

GTMTips: Prevent Clicks And Form Submits From Redirecting

Extracted from Simo Ahava's Blog Post

Using Custom beforeunload script

Google Tag Manager offers us some nice built-in triggers so that we can automatically listen for specific user interactions on the website, reacting to them however we wish, though typically it would be to fire a tag. The tricky thing especially with the click triggers and form submission tracking is that the page has a nasty habit of redirecting you to the link or form target page before letting you see the respective data in Google Tag Manager’s excellent preview mode.

>This solution should work with all redirects regardless of how they’re implemented. The trick is to add an event listener to the beforeunload browser, opening a prompt that asks if you really want to leave the current page. You can then press “Cancel” (or equivalent) to stay on the current page to see what the browser event w

@prabapro
prabapro / eecPurchases.js
Created March 25, 2020 07:04
Data Layer
<script>
// Send transaction data with a pageview if available
// when the page loads. Otherwise, use an event when the transaction
// data becomes available.
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
event: 'purchase', // MISSING EVENT NAME
'ecommerce': {
'purchase': {
'actionField': {
@prabapro
prabapro / translations.js
Created March 24, 2020 18:05
Corona App Translations
var app = angular.module("at", ["pascalprecht.translate"]);
app.config(function ($translateProvider) {
$translateProvider.translations("en", {
TITLE: "Answer these questions and check your health status for coronavirus.",
selectGender: "Select Gender",
male: "Male",
female: "Female",
yes: "Yes",
no: "No",