Google Analytics hesabına toplu ek açıklama (Annotations) ekleme

var account_id = xxxxx;
var property_id = xxxxx;
var view_id = xxxxx;

x_client_data = 'xxxxx';
x_gafe4_xsrf_token = 'xxxxx';

function annotation_create(date, text)
{
  fetch('https://analytics.google.com/analytics/app/data/admin/annotations?dataset=a' + account_id + 'w' + property_id + 'p' + view_id + '&gamonitor=gafe&hl=en_US&state=app.admin.annotation.create', {
    'headers': {
      'accept': 'application/json, text/plain, */*',
      'accept-language': 'en-US,en;q=0.9,tr;q=0.8',
      'cache-control': 'no-cache',
      'content-type': 'application/json;charset=UTF-8',
      'pragma': 'no-cache',
      'sec-ch-ua': '" Not;A Brand";v="99", "Google Chrome";v="91", "Chromium";v="91"',
      'sec-ch-ua-mobile': '?0',
      'sec-fetch-dest': 'empty',
      'sec-fetch-mode': 'cors',
      'sec-fetch-site': 'same-origin',
      'x-client-data': x_client_data,
      'x-gafe4-xsrf-token': x_gafe4_xsrf_token
    },
    'referrer': 'https://analytics.google.com/analytics/web/',
    'referrerPolicy': 'strict-origin-when-cross-origin',
    'body': '{"starred": false, "text": "' + text + '", "visibleForAllUsers": true, "visibleAcrossReports": true, "date": ' + date.replace(/-/g, '') + '}',
    'method': 'POST',
    'mode': 'cors',
    'credentials': 'include'
  });
};


var annotations = [
  {
    "date": "2021-01-01",
    "text": "Resmi Tatil: Yılbaşı"
  },
  {
    "date": "2021-04-23",
    "text": "Resmi Tatil: 23 Nisan Çocuk Bayramı"
  },
  {
    "date": "2021-05-01",
    "text": "Resmi Tatil: 1 Mayıs Emek ve Dayanışma Günü"
  },
  {
    "date": "2021-05-12",
    "text": "Resmi Tatil: Ramazan Bayramı Arefe Günü"
  },
  {
    "date": "2021-05-13",
    "text": "Resmi Tatil: Ramazan Bayramı 1. Gün"
  },
  {
    "date": "2021-05-14",
    "text": "Resmi Tatil: Ramazan Bayramı 2. Gün"
  },
  {
    "date": "2021-05-15",
    "text": "Resmi Tatil: Ramazan Bayramı 3. Gün"
  },
  {
    "date": "2021-05-19",
    "text": "Resmi Tatil: Atatürk’ü Anma Gençlik ve Spor Bayramı"
  },
  {
    "date": "2021-07-15",
    "text": "Resmi Tatil: Demokrasi ve Milli Birlik Günü"
  },
  {
    "date": "2021-07-19",
    "text": "Resmi Tatil: Kurban Bayramı Arefe Günü"
  },
  {
    "date": "2021-07-20",
    "text": "Resmi Tatil: Kurban Bayramı 1. Günü"
  },
  {
    "date": "2021-07-21",
    "text": "Resmi Tatil: Kurban Bayramı 2. Günü"
  },
  {
    "date": "2021-07-22",
    "text": "Resmi Tatil: Kurban Bayramı 3. Günü"
  },
  {
    "date": "2021-07-23",
    "text": "Resmi Tatil: Kurban Bayramı 4. Günü"
  },
  {
    "date": "2021-08-30",
    "text": "Resmi Tatil: Zafer Bayramı"
  },
  {
    "date": "2021-10-29",
    "text": "Resmi Tatil: Cumhuriyet Bayramı"
  }
]

annotations.forEach(function(e) {
  annotation_create(e.date, e.text);
})

Leave a reply:

Site Footer