google-analytics

How do I set USER_ID in Google Universal Analytics tracking code in Rails?

ぐ巨炮叔叔 提交于 2019-12-04 11:24:54
Here's the Universal Analytics tracking code for my Rails-based app. (It can be found in _analytics.html.erb , which is loaded as a partial in application.html.erb ) <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-44709438-1', 'auto'); ga('set', '&uid', {{USER_ID}}); // Set the user ID using signed-in user

Google Analytics Measurement Protocol

跟風遠走 提交于 2019-12-04 11:10:02
问题 I tried to use google analytics to track some more custom data. So I thought I use the events. The following is the code I tried where I replaced the uuid and user agent : <?php function gen_uuid() { return sprintf( '%04x%04x-%04x-%04x-%04x-%04x%04x%04x', mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0x0fff ) | 0x4000, mt_rand( 0, 0x3fff ) | 0x8000, mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ), mt_rand( 0, 0xffff ) ); } $data = array( 'v' => 1, 'tid' => 'UA-*****

Send file download event from server to Google Analytics [duplicate]

ぃ、小莉子 提交于 2019-12-04 11:03:15
This question already has an answer here : How can I track downloads of files from remote websites (1 answer) Closed 2 years ago . A download link is sent to a customer via email : Hello, Please find your product here: https://www.example.com/files/yourfile.zip I'd like to track this download in Google Analytics, as a Goal conversion. Unfortunately, when the user clicks on the link, the file is directly delivered by the web server , without going trough a .html page. How to track such a direct file download inside Analytics? Should I add a dummy HTML page "in the middle", that would use the

Adding Firebase Analytics and Google Analytics in Android App

北战南征 提交于 2019-12-04 10:49:44
问题 I have implemented Firebase Analytics. It is working fine. I wish to use the Google Analytics as well. Based on the discussion here I have included the below object in the google-services.json "analytics_service": { "status": 2, "analytics_property": { "tracking_id": "<your tracking id>" } }, For Google Analytics, I have the Tracker Class public class PuzzleGamesTracker extends Application { // The following line should be changed to include the correct property id. private static final

Run multiple simultaneous tests with Google Content Experiments API

天涯浪子 提交于 2019-12-04 10:17:49
I'm trying to use Google Content Experiments API to run several A/B tests simultaneously in the same page (similar to a multivariate test). I've tried just putting all the recommended code for each test one after another, like this: <script src="//www.google-analytics.com/cx/api.js?experiment=8RsNt4b7T0aE8RC2s9R3IA">/script> <script> var chosenVariation = cxApi.chooseVariation(); var pageVariations = [ function() {}, function() { $(".block1").hide(); }, ]; $(document).ready( pageVariations[chosenVariation] ); </script> <script src="//www.google-analytics.com/cx/api.js?experiment=T3m

Get pageview's from Google Analytics API in Javascript

只愿长相守 提交于 2019-12-04 10:00:14
I am having trouble with fetching data from Google Analytics API with javascript. I can't seem to fetch anything but lets say its something basic like pageviews. I am using Analytics.js This is the code i am using to connect to GA API: (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'XXX', 'example.com'); ga('send',

Enable google analytics for single page site with # views

妖精的绣舞 提交于 2019-12-04 09:59:26
问题 I've read the similar questions, but my question is slightly different. I am implementing a single page registration processing page for a site using Kendo UI. The site has 4 pages which was generated dynamically when user clicks menu tabs. For example, when user clicks tab1 on the menu, then tab_1 would be injected into app_container container. templates as below: <div id="app_container"></div> <script id="tab_1" type="text/x-kendo-template"> //first page </script> <script id="tab_2" type=

Google Analytics demographics For Android App

独自空忆成欢 提交于 2019-12-04 09:44:35
问题 I used Google Analytics Demographics on android app using Google play service library. i have updated my android code using enableAdvertisingIdCollection(). its working fine with screens and data. But its demographics info isn't working? Please suggest how do i handle demographics. thanking you. Code : Application code : ... synchronized Tracker getTracker( TrackerName trackerId, String appKey) { Log.d("Application", "In Application class getTracker PID" + appKey); if (!mTrackers.containsKey

How do I track User IDs w/Google Analytics & no page reload after login?

烂漫一生 提交于 2019-12-04 09:16:28
We have an angular project that we want to track User IDs with Google Analytics. The problem is, when the user is logged out & first loads the site, we have the create call pass "auto" ga('create', 'UA-XXXX-Y', 'auto'); https://developers.google.com/analytics/devguides/collection/analyticsjs/ When the user logs in, there is no page load. Is it a problem to call the "create" event again with the User ID, or is there a better way to do this? ga('create', 'UA-XXXX-Y', { 'userId': 'USER_ID' }); https://developers.google.com/analytics/devguides/collection/analyticsjs/user-id You can use the set

Adding Google Analytics to Rails 4.2 app

半腔热情 提交于 2019-12-04 09:00:07
I've got a Rails 4.2 app that I've deployed with Heroku and I've tried to add Google Analytics to it. However, Google Analytics isn't picking up any sessions. Any suggestions why and how to resolve this? CODE /app/layouts/_footer.html.erb: <% if Rails.env.production? %> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga(