var startDate;
var todaysDate;
var days;
var GAME_NAME = "-Two Aliens Escape";

function getDate() {
  var today = new Date();
  var dd = String(today.getDate()).padStart(2, "0");
  var mm = String(today.getMonth() + 1).padStart(2, "0");
  var yyyy = today.getFullYear();
  startDate = yyyy + mm + dd;
}
getDate();

if (localStorage.getItem("current" + GAME_NAME) === null) {
  console.log("startedOnce");
  localStorage.setItem("current" + GAME_NAME, startDate);
  console.log("FIRST <<<<<<<<<");

  todaysDate = startDate - localStorage.getItem("current");
  console.log("BOOOOOOOOOOB:" + todaysDate);

  days = "D0" + "0" + GAME_NAME;
  console.log("CHECK FIRST>>>>>>>>>>>> " + days);

  localStorage.setItem("send", days);
  // days = 'HELLO';
  sendData(days);
}

todaysDate = startDate - localStorage.getItem("current" + GAME_NAME);

days = "D0" + todaysDate + GAME_NAME;
console.log(days);
if (
  localStorage.getItem("current" + GAME_NAME) !== null &&
  localStorage.getItem("send") !== days
) {
  days = "D0" + todaysDate + GAME_NAME;
  localStorage.setItem("send", days);

  sendData(days);
  console.log("SECOND <<<<<<<<<");
  console.log(">>>>>>>>>>>>>>>>>>YESS<<<<<<<<<<<<<<<<<<");
}

function sendData(days) {
  dataLayer.push({
    event: "ga_event",
    ga_category: "Gamepage",
    ga_action: "Return",
    ga_label: days,
    ga_noninteraction: true,
  });
  console.log("IN SEND DATA>>>>:" + days);
  console.log("data send");
}
