View ssgtm_tag_template_complete_example.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// An example tag template that makes a request to OpenWeatherMap.org | |
// and sends data about the weather to both GA4 and Universal Analytics. | |
const getAllEventData = require('getAllEventData'); | |
const getEventData = require('getEventData'); | |
const JSON = require('JSON'); | |
const sendEventToGoogleAnalytics = require('sendEventToGoogleAnalytics'); | |
const sendHttpRequest = require('sendHttpRequest'); | |
const client_id = getEventData('client_id'); |
View ssgtm_tag_template_sendEventToGoogleAnalytics_UA.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Send data to Universal Analytics | |
const getEventData = require('getEventData'); | |
const sendEventToGoogleAnalytics = require('sendEventToGoogleAnalytics'); | |
const client_id = getEventData('client_id'); | |
const events = { | |
'x-ga-measurement_id': 'UA-XXXXXX-1', // Replace with your own GA UA ID | |
'v': 1, | |
't': 'event', |
View ssgtm_tag_template_sendEventToGoogleAnalytics_GA4_extra_data.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Send data to GA4 | |
const getAllEventData = require('getAllEventData'); | |
const sendEventToGoogleAnalytics = require('sendEventToGoogleAnalytics'); | |
const events = getAllEventData(); | |
// Add extra fields to the events object: | |
events.firstname = 'Wouter'; | |
sendEventToGoogleAnalytics(events, (response) => { |
View ssgtm_tag_template_sendEventToGoogleAnalytics_GA4.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Send data to GA4 | |
const getAllEventData = require('getAllEventData'); | |
const sendEventToGoogleAnalytics = require('sendEventToGoogleAnalytics'); | |
const events = getAllEventData(); | |
sendEventToGoogleAnalytics(events, (response) => { | |
data.gtmOnFailure(); | |
}); |
View ssgtm_tag_template_sendHttpRequest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// An example tag template that makes a request to OpenWeatherMap.org | |
const JSON = require('JSON'); | |
const sendHttpRequest = require('sendHttpRequest'); | |
sendHttpRequest('https://api.openweathermap.org/data/2.5/weather?lat=52.3746027&lon=6.6810724&appid=[enter_api_key_here]&units=metric&lang=nl', (statusCode, headers, response) => { | |
response = JSON.parse(response); | |
// Do something with the response. |
View ssgtm_variable_template.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// A variable template that doesn't work, because it uses an asynchronous API. | |
const JSON = require('JSON'); | |
const sendHttpRequest = require('sendHttpRequest'); | |
sendHttpRequest('https://api.openweathermap.org/data/2.5/weather?lat=52.3746027&lon=6.6810724&appid=[enter_api_key_here]&units=metric&lang=nl', (statusCode, headers, response) => { | |
response = JSON.parse(response); | |
return response; | |
View somfy_nodejs_RPi_example.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let Gpio | |
const express = require('express') | |
const router = express.Router() | |
// Onoff cannot be installed on devices without Gpio | |
try { | |
Gpio = require('onoff').Gpio | |
} catch (err) { | |
Gpio = { | |
accessible: false |
View fuzzywuzzy_cloud_function.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fuzzywuzzy import fuzz | |
from fuzzywuzzy import process | |
def fuzzy_flask(request): | |
"""Responds to a HTTP request. | |
Args: | |
request (flask.Request): HTTP request object. | |
Returns: | |
The response text or any set of values that can be turned into a | |
Response object using |
View request_cloud_function_from_google_ads_script.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Add your own Cloud Function URL here: | |
var CLOUDFUNCTIONSURL = 'https://europe-west1-cloud-functions-example.cloudfunctions.net/example'; | |
var search_terms = ["buy nike shoes", "adidas online", "rebok cloths"]; // With some spelling errors | |
var brands = ["nike", "adidas", "reebok"]; | |
function main() { | |
var json = { | |
"searchterms": search_terms, |
View Google_Cloud_Function_Python_example.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def hello_world(request): | |
"""Responds to any HTTP request. | |
Args: | |
request (flask.Request): HTTP request object. | |
Returns: | |
The response text or any set of values that can be turned into a | |
Response object using | |
`make_response <http://flask.pocoo.org/docs/1.0/api/#flask.Flask.make_response>`. | |
""" | |
request_json = request.get_json() |
NewerOlder