ga ऑब्जेक्ट विधि संदर्भ

यह रेफ़रंस, ga ऑब्जेक्ट पर उपलब्ध तरीकों के बारे में बताता है.

तरीके की खास जानकारी

analytics.js लाइब्रेरी लोड होने के बाद, ga ऑब्जेक्ट पर यहां दिए गए तरीके उपलब्ध होते हैं. ये तरीके अभी उपलब्ध नहीं हैं, इसलिए आपको इन्हें हमेशा ga कमांड सूची के रेडी कॉलबैक का इस्तेमाल करके शुरू करना चाहिए.

ऐसा न करेंreadyCallback के बाहर के ga ऑब्जेक्ट तरीकों का इस्तेमाल करें, क्योंकि हो सकता है कि तरीके अभी उपलब्ध न हों.

var trackers = ga.getAll();

ऐसा करेंga ऑब्जेक्ट वाले तरीकों का इस्तेमाल readyCallback में करें, क्योंकि उनके उपलब्ध होने की गारंटी होती है.

ga(function() {
  var trackers = ga.getAll();
});
तरीके
create([trackingId], [cookieDomain], [name], [fieldsObject]);

लौटाए जाने वाले प्रॉडक्ट: Tracker

दिए गए फ़ील्ड के साथ एक नया ट्रैकर इंस्टेंस बनाता है.

getByName(name)

लौटाए जाने वाले प्रॉडक्ट: Tracker

बताए गए नाम के साथ ट्रैकर इंस्टेंस लेता है.

getAll()

लौटाए जाने वाले प्रॉडक्ट: Array<Tracker>

सभी ट्रैकर इंस्टेंस की जानकारी देता है.

remove(name)

लौटाए जाने वाले प्रॉडक्ट: undefined

बताए गए नाम वाले ट्रैकर इंस्टेंस को हटाता है.

तरीकों की जानकारी

create

दिए गए फ़ील्ड के साथ एक नया ट्रैकर इंस्टेंस बनाता है.

इस्तेमाल का तरीका

ga.create([trackingId], [cookieDomain], [name], [fieldsObject]);

पैरामीटर

अलग-अलग फ़ील्ड के दस्तावेज़ के लिए, फ़ील्ड रेफ़रंस देखें.

लौटाए गए प्रॉडक्ट

Tracker

उदाहरण

// Creates a default tracker for the property UA-XXXXX-Y
// and uses automatic cookie domain configuration.
ga(function() {
  var tracker = ga.create('UA-XXXXX-Y', 'auto');
})
// Creates a tracker with the name "myTracker" for the property
// UA-XXXXX-Y, sets the cookieDomain to "example.com" and specifies
// a site speed sample rate of 10%.
ga(function() {
  var myTracker = ga.create('UA-XXXXX-Y', 'example.com', 'myTracker', {
    siteSpeedSampleRate: 10
  });
});

getByName

बताए गए नाम के साथ ट्रैकर इंस्टेंस लेता है.

इस्तेमाल का तरीका

ga.getByName(name);

पैरामीटर

नाम टाइप ज़रूरी है ब्यौरा
name string हाँ मिलने वाले ट्रैकर का नाम.

लौटाए गए प्रॉडक्ट

Tracker

उदाहरण

// Gets the default tracker.
ga(function() {
  ga.getByName('t0');
});
// Gets the tracker with the name "myTracker".
ga(function() {
  ga.getByName('myTracker');
});

getAll

सभी ट्रैकर इंस्टेंस की जानकारी देता है.

ga.getAll();

लौटाए गए प्रॉडक्ट

Array<Tracker>

उदाहरण

// Logs a list of all tracker names to the console.
ga(function() {
  var trackers = ga.getAll();
  trackers.forEach(function(tracker) {
    console.log(tracker.get('name'));
  });
});

remove

बताए गए नाम वाले ट्रैकर इंस्टेंस को हटाता है.

इस्तेमाल का तरीका

ga.remove(name);

पैरामीटर

नाम टाइप ज़रूरी है ब्यौरा
name string हाँ हटाए जाने वाले ट्रैकर का नाम.

लौटाए गए प्रॉडक्ट

undefined

उदाहरण

// Removes the default tracker.
ga(function() {
  // Note that, unlike the ga command queue's remove method,
  // this method requires passing a tracker name, even when
  // removing the default tracker.
  ga.remove('t0');
});
// Removes the tracker with the name "myTracker".
ga(function() {
  ga.remove('myTracker');
});