मौजूदा लक्ष्य को अपडेट करता है. इसे अभी आज़माएं या उदाहरण देखें.
यह तरीका स्टैंडर्ड पैरामीटर के अलावा, पैरामीटर टेबल में दिए गए पैरामीटर के साथ भी काम करता है.
अनुरोध करें
एचटीटीपी अनुरोध
PUT https://www.googleapis.com/analytics/v3/management/accounts/accountId/webproperties/webPropertyId/profiles/profileId/goals/goalId
पैरामीटर
पैरामीटर का नाम | वैल्यू | जानकारी |
---|---|---|
पाथ पैरामीटर | ||
accountId |
string |
लक्ष्य अपडेट करने के लिए खाता आईडी. |
goalId |
string |
अपडेट किया जाने वाला लक्ष्य का इंडेक्स. |
profileId |
string |
लक्ष्य अपडेट करने के लिए (प्रोफ़ाइल) आईडी देखें. |
webPropertyId |
string |
लक्ष्य अपडेट करने के लिए वेब प्रॉपर्टी आईडी. |
अनुमति देना
इस अनुरोध को नीचे दिए गए दायरे के साथ अनुमति की ज़रूरत है (पुष्टि करने और अनुमति देने के बारे में ज़्यादा पढ़ें).
अनुमति देने का |
---|
https://www.googleapis.com/auth/analytics.edit |
अनुरोध का मुख्य भाग
अनुरोध के मुख्य हिस्से में, एक मैनेजमेंट.लक्ष्य संसाधन दें.
जवाब
अगर यह तरीका इस्तेमाल किया जाता है, तो जवाब के मुख्य भाग में मैनेजमेंट.लक्ष्य संसाधन दिखाई देता है.
उदाहरण
ध्यान दें: इस तरीके के लिए दिए गए कोड के उदाहरणों में इसके साथ काम करने वाली सभी प्रोग्रामिंग भाषाएं नहीं दिखाई गई हैं (इसके साथ काम करने वाली भाषाओं की सूची के लिए क्लाइंट लाइब्रेरी वाला पेज देखें).
Java
Java क्लाइंट लाइब्रेरी का इस्तेमाल करता है.
/* * Note: This code assumes you have an authorized Analytics service object. * See the Goals Developer Guide for details. */ /* * This request updates an existing Goal. */ // Construct the body of the request. Goal body = new Goal(); body.setActive(false); body.setName("My Goal"); body.setType("VISIT_TIME_ON_SITE"); // Construct the time on site details. VisitTimeOnSiteDetails details = new VisitTimeOnSiteDetails(); details.setComparisonType("GREATER_THAN"); details.setComparisonValue((long) 500.0); // Set the time on site details. body.setVisitTimeOnSiteDetails(details); try { analytics.management().goals().update("123456", "UA-123456-1", "7654321", "1", body).execute(); } catch (GoogleJsonResponseException e) { System.err.println("There was a service error: " + e.getDetails().getCode() + " : " + e.getDetails().getMessage()); }
PHP
PHP क्लाइंट लाइब्रेरी का इस्तेमाल करता है.
/** * Note: This code assumes you have an authorized Analytics service object. * See the Goal Developer Guide for details. */ /** * This request updates an existing Goal. */ // Construct the body of the request. $goal = new Google_Service_Analytics_Goal(); $goal->setActive(False); $goal->setName('My Goal'); $goal->setType('VISIT_TIME_ON_SITE'); // Construct the time on site details. $details = new Google_Service_Analytics_GoalVisitTimeOnSiteDetails(); $details->setComparisonType('GREATER_THAN'); $details->setComparisonValue(300.0); //Set the time on site details. $goal->setVisitTimeOnSiteDetails($details); try { $analytics->management_goals->update('123456', 'UA-123456-1', '756321', '2', $goal); } catch (apiServiceException $e) { print 'There was an Analytics API service error ' . $e->getCode() . ':' . $e->getMessage(); } catch (apiException $e) { print 'There was a general API error ' . $e->getCode() . ':' . $e->getMessage(); }
Python
Python क्लाइंट लाइब्रेरी का इस्तेमाल करता है.
# Note: This code assumes you have an authorized Analytics service object. # See the Goals Developer Guide for details. # This request updates an existing goal. try: analytics.management().goals().update( accountId='123456', webPropertyId='UA-123456-1', profileId='7654321', goalId=2, body={ 'active': False, 'name': 'My Goal', 'type': 'VISIT_TIME_ON_SITE', 'visitTimeOnSiteDetails': { 'comparisonType': 'GREATER_THAN', 'comparisonValue': 400 } } ).execute() except TypeError, error: # Handle errors in constructing a query. print 'There was an error in constructing your query : %s' % error except HttpError, error: # Handle API errors. print ('There was an API error : %s : %s' % (error.resp.status, error.resp.reason))
JavaScript
JavaScript क्लाइंट लाइब्रेरी का इस्तेमाल करता है.
/* * Note: This code assumes you have an authorized Analytics client object. * See the Goals Developer Guide for details. */ /* * This request updates an existing goal. */ function updateGoal() { var request = gapi.client.analytics.management.goals.update( { 'accountId': '123456', 'webPropertyId': 'UA-123456-1', 'profileId': '7654321', 'goalId': '5', 'resource': { 'active': true, 'name': 'My Goal', 'type': 'VISIT_TIME_ON_SITE', 'visitTimeOnSiteDetails': { 'comparissonType': 'GREATER_THAN', 'comparisonValue': 300 } } }); request.execute(function (response) { // Handle the response. }); }
इसे आज़माएं!
इस तरीके को लाइव डेटा पर कॉल करने और जवाब देखने के लिए, नीचे दिए गए एपीआई एक्सप्लोरर का इस्तेमाल करें. इसके अलावा, स्टैंडअलोन एक्सप्लोरर आज़माकर देखें.