File tree Expand file tree Collapse file tree 2 files changed +8
-4
lines changed
appengine/flexible/analytics Expand file tree Collapse file tree 2 files changed +8
-4
lines changed Original file line number Diff line number Diff line change 2828$ app ->get ('/ ' , function (Application $ app , Request $ request ) {
2929 /** @var Twig_Environment $twig */
3030 $ twig = $ app ['twig ' ];
31+ $ trackingId = $ app ['GA_TRACKING_ID ' ];
32+ # [START track_event]
3133 $ baseUri = 'http://www.google-analytics.com/ ' ;
3234 $ client = new GuzzleHttp \Client (['base_uri ' => $ baseUri ]);
33- $ form = [
35+ $ formData = [
3436 'v ' => '1 ' , # API Version.
35- 'tid ' => $ app [ ' GA_TRACKING_ID ' ] , # Tracking ID / Property ID.
37+ 'tid ' => $ trackingId , # Tracking ID / Property ID.
3638 # Anonymous Client Identifier. Ideally, this should be a UUID that
3739 # is associated with particular user, device, or browser instance.
3840 'cid ' => '555 ' ,
4244 'el ' => 'Hearts ' , # Event label.
4345 'ev ' => 0 , # Event value, must be an integer
4446 ];
45- $ response = $ client ->request ('POST ' , 'collect ' , ['form_params ' => $ form ]);
47+ $ response = $ client ->request ('POST ' , 'collect ' , ['form_params ' => $ formData ]);
48+ # [END track_event]
4649 return $ twig ->render ('index.html.twig ' , [
4750 'base_uri ' => $ baseUri ,
4851 'response_code ' => $ response ->getStatusCode (),
Original file line number Diff line number Diff line change 11runtime : php
22env : flex
33
4+ # [START env_variables]
45env_variables :
56 GA_TRACKING_ID : " YOUR-GA-TRACKING-ID"
6-
7+ # [END env_variables]
You can’t perform that action at this time.
0 commit comments