The following example script asynchronously requests the USD/EUR exchange rate from the Yahoo API in JSON format by using AJAX. As soon as the currency exchange rate data has been received, a GTM Event called "exchangeRate" is fired, sending the currency rate information along as "exchangeRateInfo" parameter in the data layer.

    var yahooUrl = '*';

    var myXMLHttpRequest = null;

      myXMLHttpRequest = new XMLHttpRequest();
    else if(window.ActiveXObject){
        myXMLHttpRequest = new ActiveXObject("Msxml2.XMLHTTP.6.0");
      } catch(e){
          myXMLHttpRequest = new ActiveXObject("Msxml2.XMLHTTP.3.0");
    }'GET', yahooUrl, true);
    myXMLHttpRequest.onreadystatechange = function(){    
      if(this.readyState == 4){
        if(this.status == 200){
         dataLayer.push({'event':'exchangeRate', 'exchangeRateInfo':JSON.parse(this.responseText)});

This website is making use of cookies for website analysis. Data is collected anonymously and solely for the purpose of improving the website. Do you agree to the use of cross-session cookies?