Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #6595
    SALOU
    Participant

    Hello,

    i use gmediaGallery with photobox. I enable the deeplinking for my gallery in purpose to see via Google Analytics the number of viewers per each photos.

    But i notice that GA doesn’t count those URL with the hash.

    How can i do ?

    Thanks, (and sorry for my english, i hope you’ll understand).

    #6596
    Rattus
    Keymaster
    #6597
    SALOU
    Participant

    Thank you,

    i try to search en Google, but i think i didn’t have the good keyword.

    Have a good day.

    #6731
    SALOU
    Participant

    Hello,

    i come back to you. I’m always in trouble with this hash thing and Google Analytics.
    I manage to configure Google Tag Manager like on your first link you gave to me. This work but only if the page is refresh.
    Have you an idea how to count every hash like #photobox124, #photobox125 etc… when the user watch a gallery ?

    Thank you,

    #6732
    Rattus
    Keymaster

    Try add this code to GA script:

    window.onhashchange = function() {
        ga('send', 'pageview', {'page': location.pathname+location.search+location.hash});
    };
    #6733
    SALOU
    Participant

    I don’t know how to add that to my GA code.
    I try like this, is it good ?

    <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-XXXXXX-XX', 'auto');
    window.onhashchange = function() {
        ga('send', 'pageview', {'page': location.pathname+location.search+location.hash});
    };
    </script>
    #6736
    Rattus
    Keymaster

    I think it should send on page load and on hashchange, so maybe try this:

    <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-XXXXXX-XX', 'auto');
      ga('send', 'pageview', {'page': location.pathname+location.search+location.hash});
      window.onhashchange = function() {
        ga('send', 'pageview', {'page': location.pathname+location.search+location.hash});
      };
    </script>
    #6737
    SALOU
    Participant

    Thank for your help.
    It seem that the problem is not solve. GA doesn’t count the hash url change as a page view without reloading the page…

    #6738
    SALOU
    Participant

    I found this topic on stackoverflow, maybe we have to add a little bit of code directly into Grand Media Plugin
    http://stackoverflow.com/questions/12538115/google-analytics-and-hash-anchor-doesnt-work?rq=1

    “you need to execute this after the hash has changed. I think you are executing this when the page loads. When the hash changes the page doesn’t reload so you need to run this function call explicitly again.”

Viewing 9 posts - 1 through 9 (of 9 total)
  • The forum ‘Troubleshooting’ is closed to new topics and replies.
Forum closed. Use forum at Wordpress.org: Gmedia Support Forum