I installed Piwik PRO on my website which uses vue.js and nuxt.js. The standard configuration seems to be working fine.
My only problem is with page views! Once my clients enter their username and password, the website retrieves the necessary information for its construction in the nuxt.js configuration, then looks for the information necessary to display the page in vue.js.
The problem is that I specified a default page title in my nuxt.js configuration, so for a few milliseconds during the first page load or page refresh, a default title is displayed and then replaced by the actual page title specified in the vue.js page.
Unfortunately, Piwik PRO retrieves the page title too quickly and does not allow vue.js to load the correct page title, so I end up with the wrong title. How do I modify the standard configuration so that the pageview trigger waits between 1 to 3 seconds for the correct title to load?
From this point you can decide how you’d like to trigger the first page view. You can use History API to trigger an event there or set up a virtual page view tag with trigger that matches your expectations (e.g. a datalayer push event that is fired only when the app loads for the first time).
Other option would be to delay a bit loading of the main Analytics tag by reconfiguring the “All page views” to load a bit later:
(but that might not be enough, since you mentioned “1 to 3 seconds”)
I tried to delay loading of the main analytics tag but it didn’t work.
Yes, “Track page views in SPA” is activated.
Ok, i activate “Track page view manually” and now i dont have pageviews when I log in for the first time or when I refresh the page
So what you’re saying is that i can use API from developer documentation or set up virtual page view tag from tag manager using datalayer ? I prefer the second option but i need some help, can you tell me the steps ? Or do you have documentation that explains how to do it step by step?
(small note: page title variable is not available by default. You have to create it, but it’s quite simple. Just a new Variable with type Document and title as the value)
This tag should be fired based on a dataLayer trigger. Example code for your datalayer:
Generally it’s much simpler and should work, but using timeouts is always risky Users with really slow connections might need 3 or 4 seconds to fetch all needed assets.