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 / 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",
@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 / 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

function exportToBigQuery() {
var projectId = 'learn-big-query-307011'; //GCP Project ID here
var datasetId = 'ga_gbq_data_pipeline_demo'; //GBQ Dataset ID
var tableId = 'ga_codechilli_users_by_country'; //GBQ Table ID
var spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
var values = spreadsheet.getSheetByName('data').getDataRange().getValues();
var csv = generateCSV(values);
@prabapro
prabapro / gtm-exact-scroll-percentage-jquery.md
Created January 6, 2022 17:30
GTM - Exact scroll percentage using jQuery

Check if jQuery is enabled on the site - running the below snippet on the browser console will return the result.

(function() {
    if (window.jQuery) {  
        // jQuery is loaded
        return("Yeah! JQuery loaded");
    } else {
 // jQuery is not loaded
select
timestamp_micros(event_timestamp) as timestamp_utc, -- converts the timestamp into UTC
format_datetime("%Y-%d-%m %H-%M-%S %Z", (timestamp_micros(event_timestamp)), 'America/New_York') as timestamp_newyork, --timestamp in NY
event_name,
(select value.string_value from unnest(event_params) where key = 'transaction_id') as transaction_id, -- gets the string value
(select value.int_value from unnest(event_params) where key = 'value') as transaction_value, --gets the integer value
(select value.string_value from unnest(event_params) where key = 'currency') as currency,
(select value.string_value from unnest (event_params) where key = 'page_title') as page_title,
(select value.string_value from unnest (event_params) where key = 'page_location') as url
function() {
var orderData = {{dlv - order-data v1}};
var items = {{dlv - items - v1}};
var actionField = {
id: orderData.id,
affiliation: orderData.affiliation,
revenue: orderData.revenue,
shipping: orderData.shipping,

MeasureSchool - ThriveCart Ecommerce Events (UA & GA4)

Instructions - ThriveCart

thrivecart

  1. Copy the contents from 01-base-all-pages.html & paste it on All Pages box in the ThriveCart Product Checkout page - Replace GTM-xxxxx with your GTM container ID - Line 12.

  2. Copy the contents from 02-checkout-page.html & paste it on Checkout Page box.