Skip to content

Instantly share code, notes, and snippets.

@WouterNieuwerth
Created February 27, 2022 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save WouterNieuwerth/b886b7df1cd911df2c110eb7a79c6fea to your computer and use it in GitHub Desktop.
Save WouterNieuwerth/b886b7df1cd911df2c110eb7a79c6fea to your computer and use it in GitHub Desktop.
This Server-side GTM tag template makes a request to openweathermap.org and parses the JSON response.
// 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.
}, {method: 'GET', timeout: 2000});
// Call data.gtmOnSuccess when the tag is finished.
data.gtmOnSuccess();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment