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 formID
and 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 formSubmit
as 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 page
to the data layer variable where the value of formID
is 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
So, after days, I found the issue. Still cannot explain why this is the case, but in the tag I had enabled Enable overriding settings in this tag
and had enterend into the field Tracking ID
below again the GA ID variable. Since I removed the variable and left the field blank, everything has been working.
Hope this is helpful to anybody who ever might experiencing same issues. Please, if anybody can explain why this is the case very happy to hear and learn.
Want to thank @Дмитро Булах for pointing me in the right direction with his answer. Thank you!