Skip to content

Commit 2b1617f

Browse files
averikitschbradmiro
authored andcommitted
Add region tags and readme (#1634)
1 parent 2b25806 commit 2b1617f

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

appengine-java8/analytics/README.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Google Analytics sample for Google App Engine
2+
3+
<a href="https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/GoogleCloudPlatform/java-docs-samples&page=editor&open_in_editor=appengine-java8/analytics/README.md">
4+
<img alt="Open in Cloud Shell" src ="http://gstatic.com/cloudssh/images/open-btn.png"></a>
5+
6+
Integrating App Engine with Google Analytics.
7+
8+
## Project setup, installation, and configuration
9+
10+
- Register for [Google Analytics](http://www.google.com/analytics/), create
11+
an application, and get a tracking Id.
12+
- [Find your tracking Id](https://support.google.com/analytics/answer/1008080?hl=en)
13+
and set it as an environment variable in [`appengine-web.xml`](src/main/webapp/WEB-INF/appengine-web.xml).
14+
15+
## Running locally
16+
This example uses the
17+
[Maven Cloud SDK based plugin](https://cloud.google.com/appengine/docs/java/tools/using-maven).
18+
To run this sample locally:
19+
20+
$ mvn appengine:run
21+
22+
## Deploying
23+
24+
$ mvn appengine:deploy

appengine-java8/analytics/src/main/java/com/example/appengine/analytics/AnalyticsServlet.java

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.example.appengine.analytics;
1818

19+
// [START analytics_track]
1920
import com.google.appengine.api.urlfetch.URLFetchService;
2021
import com.google.appengine.api.urlfetch.URLFetchServiceFactory;
2122
import java.io.IOException;
@@ -67,3 +68,4 @@ public void doGet(HttpServletRequest req, HttpServletResponse resp)
6768
resp.getWriter().println("Event tracked.");
6869
}
6970
}
71+
// [END analytics_track]

appengine-java8/analytics/src/main/webapp/WEB-INF/appengine-web.xml

-1
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,3 @@
2020
<env-var name="GA_TRACKING_ID" value="YOUR-GA-TRACKING-ID" />
2121
</env-variables>
2222
</appengine-web-app>
23-

0 commit comments

Comments
 (0)