Search code examples
angularjsangular-ui-routergoogle-index

How does Angular router and dynamic links work with Google services?


I am in the end of a project involving an admin / frontend angularjs. Within this project there is a blog and a space for project post.

I have some questions regarding the links created by the angular, because they are dynamic:

  • The Google indexes those links? If not, is there any way?
  • The links created by the angular, can I use Google Analytics to access their statistics?

I did not see another place to have posted my doubts because I know that the stackoverflow only have people in angular beast.

.state('home.posts',{
    url         : '/blog/:slug',
    templateUrl : 'content/templates/single.html',
    theme       : 'indigo',
    controller: function(ApiRestangular, $stateParams, $scope){
        ApiRestangular.all('posts').getList({filter: {slug: $stateParams.slug}}).then(function(res){
            $scope.item = res[0];
        });
    },
    data: {
        pageTitle: 'title'
    },
    access: {
        requiredLogin: false
    }
})

Solution

  • The Google indexes those links? If not, is there any way?

    Google can't index this link. You can use http://phantomjs.org/ to generate static pages. Read this article for details http://www.ng-newsletter.com/posts/serious-angular-seo.html

    The links created by the angular, can I use Google Analytics to access their statistics?

    Yes, you can. You can use Angulartics https://luisfarzati.github.io/angulartics/ or write your own service or directive which will send event to google analytics based on your rul.