Skip to content

Instantly share code, notes, and snippets.

@sahava
sahava / Dockerrun.aws.json
Created Jun 2, 2021
Sampe Dockerrun.aws.json for running a GTM tagging server in AWS Elastic Beanstalk
View Dockerrun.aws.json
{
"AWSEBDockerrunVersion": "1",
"Image": {
"Name": "gcr.io/cloud-tagging-10302018/gtm-cloud-image:stable",
"Update": "true"
},
"Ports": [
{
"ContainerPort": 8080
}
@sahava
sahava / template.tpl
Created May 6, 2021
Simmer Client - Custom Client Template for Google Tag Manager Server containers. This is a "minimum viable Client" template, designed as an example for the Simmer course on server-side tagging.
View template.tpl
___INFO___
{
"type": "CLIENT",
"id": "cvt_temp_public_id",
"version": 1,
"securityGroups": [],
"displayName": "Simmer Client",
"brand": {
"id": "brand_dummy",
@sahava
sahava / template.tpl
Created Mar 4, 2021
Event Data To BigQuery - DEMO of the BigQuery API
View template.tpl
___INFO___
{
"type": "TAG",
"id": "cvt_temp_public_id",
"version": 1,
"securityGroups": [],
"displayName": "Event data to BigQuery",
"brand": {
"id": "brand_dummy",
@sahava
sahava / gtmContainerPolicy.js
Created Feb 20, 2021
Sample Server container policy file
View gtmContainerPolicy.js
gtag('policy', 'all', function(container, policy, data) {
switch (policy) {
// Only allow _ga cookie to be set.
case 'set_cookies':
return data.name === '_ga';
// All other permission requests are allowed.
case 'access_response':
case 'access_template_storage':
@sahava
sahava / template.tpl
Last active Apr 13, 2021
Facebook (updated) - Custom Template demo
View template.tpl
___INFO___
{
"type": "TAG",
"id": "cvt_temp_public_id",
"version": 1,
"securityGroups": [],
"displayName": "Facebook",
"brand": {
"id": "brand_dummy",
@sahava
sahava / template.tpl
Last active Apr 13, 2021
Facebook - Custom Template demo
View template.tpl
___INFO___
{
"type": "TAG",
"id": "cvt_temp_public_id",
"version": 1,
"securityGroups": [],
"displayName": "Facebook",
"brand": {
"id": "brand_dummy",
@sahava
sahava / template.tpl
Last active Feb 16, 2021
Advanced Universal Analytics (updated) - Custom Template demo
View template.tpl
___INFO___
{
"type": "CLIENT",
"id": "cvt_temp_public_id",
"__wm": "VGVtcGxhdGUtQXV0aG9yX0FkdmFuY2VkVW5pdmVyc2FsQW5hbHl0aWNzLVNpbW8tQWhhdmE\u003d",
"categories": [
"ANALYTICS"
],
"version": 1,
@sahava
sahava / template.tpl
Last active Feb 13, 2021
Advanced Universal Analytics - Custom Template demo
View template.tpl
___INFO___
{
"type": "CLIENT",
"id": "cvt_temp_public_id",
"__wm": "VGVtcGxhdGUtQXV0aG9yX0FkdmFuY2VkVW5pdmVyc2FsQW5hbHl0aWNzLVNpbW8tQWhhdmE\u003d",
"categories": [
"ANALYTICS"
],
"version": 1,
View dataLayer-push-listener.js
(function() {
var oldPush = window.dataLayer.push;
window.dataLayer.push = function() {
var states = [].slice.call(arguments, 0);
// do what you want here
// in response to dataLayer.push()
return oldPush.apply(window.dataLayer, states);
}
View LookupTableGenerator.gs
// Parse the IDs from the first four rows of the sheet
function getIds() {
const sheet = SpreadsheetApp.getActiveSheet();
const ids = {
accountId: sheet.getRange('B1').getValue().toString(),
containerId: sheet.getRange('B2').getValue().toString(),
workspaceId: sheet.getRange('B3').getValue().toString(),
variableId: sheet.getRange('B4').getValue().toString()
};
if (ids.workspaceId.toLowerCase() === 'default') ids.workspaceId = getDefaultWorkspaceId(ids.accountId, ids.containerId);