question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Initial page load tracking not calling pageTrackerTemplate

See original GitHub issue

Description

Initial page loaded is being tracked incorrectly. pageTrackerTemplate is not being called.

Expected behavior

When loading the site, I’d expect the tracking of the initial page to call pageTrackerTemplate to get my custom title value.

Actual behavior

An event is sent with the actual document title which is not what I want to send. For example, my route.meta.title is set to ‘Classes’. However, I have a router.afterEach hook that prepends 'Site Name | ’ to it and sets document.title.

Environment

Run this command in the project folder and fill in their results:

npm ls vue-gtag: vue-gtag@1.6.2

Then, specify:

  1. Operating system: Linux Mint
  2. Browser and version: Chrome Version 81.0.4044.92 (Official Build) (64-bit)

Reproducible Demo

const routes = [
	{
		name: 'home',
		path: '/',
		component: () => import('pages/Home.vue'),
		meta: {
			title: () => 'Home',
		},
	},
]
router.afterEach((to, from) => {
	if (to.meta && to.meta.title) {
		const title = to.meta.title(to)
		if (title) {
			document.title = 'My Site | ' + title
		} else {
			document.title = 'My Site'
		}
	}
})
pageTrackerTemplate(to, from) {
	const trackingData = {
		page_title: to.meta.title ? to.meta.title(to) : to.name,
		page_path: to.path,
		page_location: window.location.href,
	}
	return trackingData
},

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
m1stermanagercommented, Jun 21, 2020

@MatteoGabriele I’ve had a week off at work and I’ll be checking this out monday in the AM… I’ll let you know how it goes! thanks for the effort on this and the quick turnaround.

0reactions
m1stermanagercommented, Jun 29, 2020

unrelated issues kept us from making this change, i’ll see if I can get it in first thing in the morning. thanks again for the project, documentation, and responsiveness

Read more comments on GitHub >

github_iconTop Results From Across the Web

onRouteChangeCompleted not called on first page load #4662
Bug report Describe the bug Should Router.onRouteChangeCompleted be called on first page load? If not, what is the recommended way to track ......
Read more >
Auto tracking - vue-gtag - GitBook
The automatic tracker system can use a custom template, instead of the default one: this will apply whether you are using pageviews or...
Read more >
How to call a vue.js function on page load - Stack Overflow
My issue was that I did not know to use "this" in the mounted() section, and I was getting function undefined errors. "This"...
Read more >
How to Track Single Page Applications with Google Tag ...
This is a tutorial on how to track single page applications (SAPs) with Google Tag Manager. Learn how with the GTM history trigger...
Read more >
How to record Vuejs(SPA) page load time?
Hi All, I use Vuejs as frontend framework together with NewRelic. Although newRelic seems to record the page loading time by default. After ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found