1

I used following formula get UPS live tracking feed and it works fine until yesterday. I think UPS has updated their site and this formula does not work anymore. Any idea or suggestions for how to get the tracking update from UPS?

=Index(IMPORTXML("https://wwwapps.ups.com/WebTracking/track?track=yes&trackNums="&A1,"//*[@id='tt_spStatus']"),1)

Now I am getting an error:

Imported content is empty

starball
  • 20,030
  • 7
  • 43
  • 238
PrasadD
  • 77
  • 1
  • 9

4 Answers4

3

UPS updated this webpage. It no longer returns tracking information in the initial page response. It now instead makes a separate AJAX request to retrieve the information after the page is loaded.

Use this formula instead with the URL updated to a different page on their site that returns tracking information in the initial page response:

=Index(IMPORTXML("https://wwwapps.ups.com/tracking/tracking.cgi?tracknum="&A1,"//*[@id='tt_spStatus']"),1)
Arnell
  • 46
  • 1
1

With Delivery Time and status where A1 has tracking code.

=index(IMPORTXML("https://wwwapps.ups.com/tracking/tracking.cgi?tracknum="&A1,"//*[contains(@class,'ups-group')]"),2)

Sudeep
  • 21
  • 1
  • 3
  • this will only give me deliver date tho. How do I get the current status like in transit or Delivered. Thank you – PrasadD Jan 30 '19 at 18:27
0

Tracking with a few extra details (Where A1 is tracking no.):

=iferror(
  IMPORTXML(
    "https://wwwapps.ups.com/tracking/tracking.cgi?tracknum="&$A1,"//*[@id='tt_spStatus']")&iferror(": "&substitute(index(index(IMPORTHTML("https://wwwapps.ups.com/tracking/tracking.cgi?tracknum="&$A1,"table"),2),1),",  United States",""),""
  ),
  "--"
)

Result for package ready to ship: "Order Processed: Ready for UPS"

Result for in-transit parcel: "Picked Up: Atlanta, GA"

Joe Tricarico
  • 363
  • 2
  • 5
0

None of these work for me in 2020 but here's what does:

Add this function in script editor:

function IMPORTJSON(url,xpath){

  try{
    // /rates/EUR
    var res = UrlFetchApp.fetch(url);
    var content = res.getContentText();
    var json = JSON.parse(content);

    var patharray = xpath.split("/");
    //Logger.log(patharray);

    for(var i=0;i<patharray.length;i++){
      json = json[patharray[i]];
    }

    //Logger.log(typeof(json));

    if(typeof(json) === "undefined"){
      return "Node Not Available";
    } else if(typeof(json) === "object"){
      var tempArr = [];

      for(var obj in json){
        tempArr.push([obj,json[obj]]);
      }
      return tempArr;
    } else if(typeof(json) !== "object") {
      return json;
    }
  }
  catch(err){
      return "Error getting data";  
  }

}

This formula will output transit status in your cell:

=IMPORTJSON(join("","http://shipit-api.herokuapp.com/api/carriers/ups/",A1),"activities/0/details")

I don't need the other details, so I made another cell that has a link to the ups tracking page if any other users need more information:

=HYPERLINK("https://www.ups.com/track?loc=en_US&tracknum="&A1&"&requester=WT/trackdetails)")