How to Track Google Analytics Page Views ?

Tracking Google Analytics Page Views with AngularJS
Asked on October 16, 2018 in AngularJs.
Add Comment


  • 5 Answer(s)

                  Even though  utilizing ng-see in Angular application can tune  for the $viewContentLoaded  occasion and drive a following occasion to Google Analytics.

                  Expecting this following code is based on  index.html record with a name of var gaq and  My Ctrl is the thing that characterized in the ng-controller mandate.

    function MyCtrl($scope, $location, $window)
    {
    $scope.$on('$viewContentLoaded', function(event)
    {
    $window._gaq.push(['_trackPageView', $location.url()]);
    });
    }
    

                  UPDATE:  for new form of google-investigation utilize this one

    function MyCtrl($scope, $location, $window)
     {
    $scope.$on('$viewContentLoaded', function(event)
     {
    $window.ga('send', 'pageview', { page: $location.url() });
    });
    }
    
    Answered on October 16, 2018.
    Add Comment

    Here is a service which you could use:

    (function(angular)
    {
    angular.module('analytics', ['ng']).service('analytics', [
    '$rootScope', '$window', '$location', function($rootScope, $window, $location)
    {
    var track = function()
    {
    $window._gaq.push(['_trackPageview', $location.path()]);
    };
    $rootScope.$on('$viewContentLoaded', track);
    }
    ]);
    } (window.angular));
    

    When it defines  angular module, include the analytics module also:

    angular.module('myappname', ['analytics']);
    
    Answered on October 16, 2018.
    Add Comment

    The following command sends a pageview hit to Google Analytics and includes the path of the current page:

    ga('send', 'pageview', location.pathname);
    
    
    Answered on December 16, 2018.
    Add Comment
    app.run(function ($rootScope, $location) {
        $rootScope.$on('$routeChangeSuccess', function(){
            ga('send', 'pageview', $location.path());
        });
    });
    Answered on January 18, 2019.
    Add Comment

    The Top Content report in Google Analytics allows you to see the most popular pages on your website ranked according to the number of page views. Using this report, you can see how the individual pages on your website have performed over a selected time frame. Use the Top Content report to find out which pages on your website are most popular, how many people have viewed it and how much money it has earned through the Google AdSense program.

    1.

    Navigate to analytics.google.com in your Web browser. Click the “Access Analytics” button on the right side of the page and enter your Google account email address and password if prompted.

    2.

    Click the “View report” link next to the website on which you want to track page views. This displays the Dashboard page for the selected website.

    3.

    Scroll to the bottom of the page and click the “View Report” link at the bottom of the “Content Overview” section.

    4.

    Scroll to the bottom of the page and click the “View Full Report” link at the bottom of the “Top Content” section. This screen shows the number of page views that each page on your website has received. The page with the most views is displayed first.

    5.

    Click the date range at the top of the page to adjust the time period that the report should display data from.

    6.

    Click the drop-down menu next to “Show Rows” at the bottom of the screen and select a larger number to display more of your website’s pages on the screen simultaneously.

    7.

    Click any page on the list to see a report detailing the amount of time people have spent on the page, the bounce rate and the amount of AdSense earnings (if applicable).

    Tip

    • Pages that have not received views during the time period you select will not be displayed on the Top Content report on Google Analytics.
    Answered on February 9, 2019.
    Add Comment


  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.