I'm trying to set up a different page's title. I put that code on the head of the page:
<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/analytics.js','ga');
ga('create', 'UA-XXXXXXX-Y');
ga('send', 'pageview');
ga('set', 'title', 'Invitation');
</script>
I'd like to set up the 'title' as 'Invitation' but I have no feedback from Google Analytic's side. Obviously I changed UA-XXXXXXX-Y into my personal code. Right now I can only see that the page has been visited but it has the page's default title instead of the overridden one.
I'm trying to set up a different page's title. I put that code on the head of the page:
<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./analytics.js','ga');
ga('create', 'UA-XXXXXXX-Y');
ga('send', 'pageview');
ga('set', 'title', 'Invitation');
</script>
I'd like to set up the 'title' as 'Invitation' but I have no feedback from Google Analytic's side. Obviously I changed UA-XXXXXXX-Y into my personal code. Right now I can only see that the page has been visited but it has the page's default title instead of the overridden one.
Share Improve this question asked Oct 16, 2013 at 19:35 GiulioGiulio 8038 silver badges22 bronze badges2 Answers
Reset to default 6Pass the title as an additional and optional parameter when you send the pageview.
ga('send', 'pageview', {
title: 'Invitation'
});
There is more info on page tracking on google developers.
You'd need to swap the send and set calls. Any set
calls need to be before a send
call.
<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./analytics.js','ga');
ga('create', 'UA-XXXXXXX-Y');
ga('set', 'title', 'Invitation');
ga('send', 'pageview');
</script>
FYI - By utilizing the set
mand you'll be changing the page title for all subsequent calls on that page. If you pass it as an optional parameter as in Blexy's example, it'll only change it for that single call. All subsequent calls will then use the default value.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742299883a4417837.html
评论列表(0条)