Created
February 27, 2022 13:00
-
-
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.
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. | |
}, {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