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)});

Cookies make it easier for us to provide you with our services. With the usage of our services you permit us to use cookies.
More information Ok