Analytics
3.2K members online now
3.2K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

A question about Virtual Pageview

Follower ✭ ✭ ✭
# 1
Follower ✭ ✭ ✭

Hi,

 
I have a website where If a user fills a form at  xyz.com/contactus  and after a successful submission the  browser loads /xyzn.com/contactus/ again, the default Google Analytics setup will register 2 pageviews for the /contactus/ page.
 
I would like to solve it through Virtual pageviews.  My questions are :
 
1 ) What's the code for implementing virtual pageviews in this situation and
 
2 ) where do i implement the code in GA
 
Cheers
1 Expert replyverified_user

A question about Virtual Pageview

Top Contributor
# 2
Top Contributor

I usually add it to the form tag using an onsubmit
eg

<form onsubmit="ga('send', 'pageview', '/contactsuccess');">

 

</form>

 

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

A question about Virtual Pageview

Follower ✭ ✭ ✭
# 3
Follower ✭ ✭ ✭

Thanks Bronwyn.  How can i view in GA report that the customer has succesfully submitted the form. 

A question about Virtual Pageview

Top Contributor
# 4
Top Contributor

If you test it. provided you aren't filtering/blocking your own visits from being tracked

you should be able to see it in the Real Time reports as a tracked page /contactsuccess (or whatever request URI you use for it when setting up the code)
and once the data is processed into the standard reports then it will appear in the pageview reports like other real pages being tracked.

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here

A question about Virtual Pageview

Follower ✭ ✭ ✭
# 5
Follower ✭ ✭ ✭

Thanks for your quick response.

 

Is this code also correct:

 

ga('send', { 'hitType': 'pageview', 'page': '/contactus/submitted/', 'title': 'Contact Us Submitted' }); 

 

If yes,

 

1 ) after which line of code i will have to place the above code in GA code

 

2 ) What title or URL will be shown in reports and will these be shown in standard reports like usual reports.

 

Many Thanks

Marked as Best Answer.
Solution
Accepted by topic author Jackspwter
February 2017

A question about Virtual Pageview

[ Edited ]
Top Contributor
# 6
Top Contributor

Is this code also correct:

ga('send', { 'hitType': 'pageview', 'page': '/contactus/submitted/', 'title': 'Contact Us Submitted' }); 

 

I've not ever done it like that, but it should still work

 

1 ) after which line of code i will have to place the above code in GA code
If you look back a couple of posts I did provide the code I would use in for form tag using onsubmit

 

2 ) What title or URL will be shown in reports and will these be shown in standard reports like usual reports.
My last post did address where it would be found in the reports and how it would appear regarding the page request uri. same applies for the title.. whatever you put in there as the parameter.

eta.. often the best way to see is to set something up and test it, then you can see how it behaves within your own reports etc.

Bronwyn Vourtis, Google Analytics Top Contributor
Was my response helpful? If yes, please mark it as the ‘Best Answer.’ Learn how here