字幕表 動画を再生する 英語字幕をプリント >> Hi. My name is Nick. And today, we're going to talk about Goal Configuration Data in the Google Analytics API. Today, we're going to discuss the type of goals, what new data is available, and we're going to go through a simple example in Java. Let's begin. Currently, there are three ways to configure goals in Google Analytics. The most common way is to define a goal conversion when a visitor visits a page or group of pages. This is called the "destination-type goal." Recently, in Google Analytics Version 4, the user can configure a goal when a visitor spends more than a period of time. Also new in Version 4 is the ability to configure a goal when a visitor visits a number of pages. Both Time-based, and Pages Per Visit goals are called "engagement-type goals." The Google Analytics API exposes different data for both type of goals. Let's see what data's available. Here is an example of the XML return from the Account Feed of the API. The Account Feed has a number of entry elements that describe each profile the authorized user can access. Because goals are configured per profile, each entry now contains goal configuration data. Within each goal are type-specific elements, including destination type goal -- and all of their configured steps -- or engagement-type goals. Let's look closer at the goal XML element. Currently, there can be up to 20 goal elements in each Account Feed entry. Within each goal are XML attributes describing the goal's number, the goal's name, whether the goal is active, and the goal's value. This data is common to both destination and engagement-type goals. And only the child elements are specific to either goal type. Here is the XML specific to a destination-type goal. Each attribute describes the expression configured to match on a page or group of pages, the match type, whether the goal is case-sensitive, and whether the first step is required. Each destination goal can be configured to report up to ten steps that led into the goal. Each step has attributes describing its number, its name, and its path. Here is the XML specific to an engagement type goal. The type attribute differentiates between goals configured for either time on site or the number of pages visited. The comparison and threshold value attributes describe under what conditions a goal will be triggered. Let's now look at a simple example in Java. Here is a simple code example that prints all the goal information. This example defines a class called the Account Feed example with three private members to store the user name, the user's password, and the object returned from the API. In the main method, a new account feed example object is created, then all the goal information is printed. That's the entire program. Let's look at the constructor. [pause] In this example, the constructor is responsible for retrieving data from the API. First, the new analytic service object is created with the name of our application. Then, the username and password is set using the 'set user credentials' method. Specify we want to use the 'client login authorization' routine. Next, the URL object is created to query the account feed. And finally, we use the analytics service class get feed member to make a request to the API and return the data in an account feed object. Now, we're ready to print the data. [pause] When the print goal configuration data method is called, this class' account feed member already has data from the API. Since goal data is inside each entry element, we first need to check if the data returned has entries. If it does, we then check if any goals have been configured for this profile. Then, for each goal we print the goal name, the number, the goal's value, and whether the goal is active. We then see if this is a destination or engagement-type goal, then use the Java client library's 'helper methods' to either get the destination data or the engagement data and pass the results to the appropriate print method. If this is a destination goal, we simply print the expression match type if step one is required and if the goal is case sensitive. Since each destination goal can have up to ten steps, we check that the goal has steps configured, then iterate through each step and print the step's number, name, and path. Now, if this is an engagement goal, we simply print the type of goal, the comparison operator, and the threshold value. That's it. The simple example will print all the new goal configuration data. Hopefully, you now have a better understanding of how to access goal configuration data from the Google Analytics API. If you want to learn more, check out our online documentation at code.Google.com/APIs/analytics. Also the complete Java example is available for your reference on Google Project Hosting. Thanks.
B1 中級 GoogleアナリティクスAPIのゴール設定データ (Goal Configuration Data in the Google Analytics API) 46 10 Chris Lyu に公開 2021 年 01 月 14 日 シェア シェア 保存 報告 動画の中の単語