How to track a virtual page view with GTM. Dozens of tutorials, checked them all and tried from scratch a couple of times. Issue: Page Path (aka "page") value in GA not set to what I defined in GTM.
Explanation: The page I want to track is technically one page (form.php), featuring a multi-step form. So, several html forms after each other. The end goal is that on the (successful) submit of each form a virtual pageview will be triggered. As the mechanic is based on jQuery, I plan to use a data layer push event as the trigger. Step by step:
Defined a DataLayer variable in GTM for the page path called
formIDand prior to the event (used as trigger) set the value, formatted as a relative path:dataLayer.push({ 'formID':'/form-start' });Set an event with the name
formSubmitas the trigger and trigger it with:dataLayer.push({'event': 'formSubmit'});In the tracking ID variable as well as in the tag itself, I set the Field Name
pageto the data layer variable where the value offormIDis stored
Testing in the console, both in the preview as well as in the published container, even after refresh, deleting cookies and much more, I get the following results:
In the DataLayer tab in the preview, I can see:
event: 'formSubmit',
formID: '/form-start'
In the Variables tab in the preview, I can see the tag fired, and for the Google Analytics settings and the Tracking ID:
fieldsToSet: [
{fieldName: 'anonymizeIp', value: 'true'},
{fieldName: 'page', value: '/form-start'},
...
However, in the Variables tab as well as in Google Analytics, Page Path is still '/form.php'.
Please, can anybody give me a hint what I am missing here? Any help very much appreciated.
Edit: Screenshots attachements
tag setup (hint: I added dp as a test, as I read in one forum to try the measurement protocol parameters)
trigger configuration
DataLayer variables when testing




formIDset at the same time or before theformSubmitevent fires? If the answer is no, then there is your problem. - vinoaj