Add goal in google analytics for a framed page - asp.net

I have a page in ASP.NET C#, In my page I have iframe with another page. I want to add a Goal in Google analytics when people press the Submit-linkbutton in the framed page.
While my url doesnt change when I press the submit button I have heard that you can use the following javascript to tell Analytics that you´re on the specified page:
pageTracker._trackPageview('/booking.html');
So I have added the following line in the page_load function:
SubmitButton.Attributes.Add("onclick", "pageTracker._trackPageview('/booking.html');");
And in Google analytics have I added the goal url:
/booking.html
But nothing happends in the goal section when I press the submit button.
Im really not sure of what im doing so some help had been really appreciated.
Martin

Since iframes are treated as completely separate pages, I suspect you need to add the tracking code to the framed content as well.
You might also try calling a function in the parent page which triggers the page tracker:
SubmitButton.Attributes.Add("onclick", "parent.TrackPageView(window.location.href)");

Related

Google Tag Manager - Count visit on lazy load post

I have a Wordpress page, and I developed an "Infinite Scroll" for posts. When I am reading a post and scroll to bottom, the page load another post using Ajax (and change the URL) but without windows refresh.
I need (my client) that when someone scroll down and a new post is loaded, that load count a visit on Google Tag Manager, as if that person should enter to that post directly.
Is this possible?
Thank you.
Try history change trigger. It often helps when the URL changes without page loads.
A proper solution here, however, would be modifying the lazy loading function to issue a dataLayer event whenever a new post is loaded.
Another hack for it would be using the visibility trigger. And use it for, let's say, your post headers. And then pass that header in an event.
Then you will be able to conduct classical per-post impressions-to-clicks analysis. CTR, basically.

Google Analytics Phone Number Tracking in Wordpress?

I am trying to figure out how to add tracking with Google Analytics to multiple phone numbers on a Wordpress site. I saw this page from and earlier Stack Overflow post but I wasn't sure if it was up to date. I noticed somewhere else (here) on a Google search that said you have to add an Event in your GA account first and then add that code. Is this correct? Or do you just have to add the code itself to the Wordpress site without adding an Event in GA?
Also, if it's code for a link, can I highlight the phone number and put the code into the link area (as in chain link in the Visual Editor) on the page, or do I have to place this code in the Text Editor part of the page?
I'm using the current UA right now.
Also, I'm really new to this event tracking stuff, so please accept my apologies if I stated/asked anything incorrectly. Thanks in advance for any and all feedback.
Add a class to all your phone number instances within your HTML. ie class="tel">
Write a click function on that class, and then push the ga following the correct version syntax.
ga('send', 'event', 'category', 'action');
So:
$('.tel').click(function() {
ga('send', 'event', 'Category1', 'Action1', 'Demo!');
});
Use Google Tag Manager. It's great tool. There is also a plugin: DuracellTomi's Google Tag Manager for WordPress. You must read some documentation about GTM but when you will know GTM you can track almost anything on your site.

Google Analytics: Visitors flow: Only showing root with 100% drop off, no pages

I would like to use the google analytics visitors flow tool but it does not show any specific page. All visits are in one big block "/". If I click on "group details" pages are listed just fine.
My site uses url parameters like mypage.com?p=products to switch between pages. I have managed to set up analytics so that it understands this and works on the "content" page and everywhere. How can I make it also work with "visitors flow" to display specific pages?
this might be the same problem: Google Analytics: 100% Drop off from landing page
Just noticed that links on my page are missing the slash before the "?". will add the slash and report back.
Edit: Though I guess that was an improvement it did not solve the problem.
I am using absolute links (http:/mysite.com/?p=contact) all over the place. Should I try relative links to get this to work?
Yes, you need to put a / before the ? in your links or else Analytics could interpret your full URL as the domain/sub-domain and not report any page paths or levels (like you're observing).
Additionally, are you sure the Analytics script is firing whenever a new page is loaded? Clicking through your site it looks like the base page template may not be reloading whenever you click to a different page (only the content is reloaded). If this is the case and the Analytics script is part of your base template, it would only fire once when the visitor first enters the site and load the page template and never again. Since Google Analytics calculates pageviews and time on site/page based on the difference in time between when the _trackPageview() is fired, it could explain your problem.
I would suggest moving your Analytics script to a portion of the markup that is reloaded every time someone clicks to a new page to see if this does the trick.

Google Analytics in Wordpress - Cross-Domain Tracking

I've searched high and low for an answer for this problem and need the help of experts.
The website I'm helping to oversee has a registration in a frame on their main website. When a user visits the site, they can choose which course to take and click on a "Register" link to be taken to the externally hosted form.
I was able to get the GA tags changed on the framed pages, so that step is done.
However, I realise that in order to properly cross-domain track with Google Analytics, I need to also add an onclick event to any links that bring users to those pages, such as the example below.
Link
However, the site I'm working with is in Wordpress, and when I view the link in there it looks like this:
[iab_event link="http://www.EXAMPLESITE.com/course/4105/register.asp" text="Register"]
And when you view the page source of the live site this link is translated to this:
Register
I tried adding the second onclick event to the one above, but that didn't work. Is there any way to add the onClick="pageTracker._link('http://www.EXAMPLESITE.com/course/4105/register.asp'); return false;" to this link without breaking it?
Thank you in advance for any advice given!
Try stacking them in the onclick event like this:
Register
It should run all of the commands as long as they're separated by semi-colons.

Google Virtual Pageview Setup

I need some help with the setup of tracking virtual clicks on a submit button. What I need to do is get the referring site, which Google already tracks, and then track if they click on the button. I have setup an onclick for the submit button and setup a goal in Analytics but it is not tracking. I do have the code in place for Analytics in my header to track pageviews.
So what I am trying to do right now with my goal is to track a referring website and then track who clicks on the button. The virtual view I am using for the click is:
onclick="pageTracker._trackPageview('/Orders/Subscription');"
Thank you for any help in getting this setup working. I am still working on learning analytics.
If you want to ...get the referring site, which Google already tracks at the time the user clicks the submit button, you will have to read the cookies (the _utmz in this case) that GA sets and extract it from there.
Referral data can be obtained from the reports in GA, but if you want it at the time of submit, you'll have to get it from the cookies. Plain vanilla javascript can do this for you, just google it. Or, use whatever language your pages are written in to extract the data from the cookie (PHP and many others have this capability).
Regarding tracking the virtual page view, if the user can submit your form by hitting the enter key, then onclick is not desirable. onsubmit in the form tag would be better.
If it is still not recording for you, make sure your goal steps are entered into GA correctly (it's quite common to mess this up and GA is not forgiving to even the slightest error) and that you are using the traditional tracking snippet in the head of your document because your example is in the traditional tracking format. You should not mix async and traditional snippets.
To check if GA is even tracking your virtual page, go to the Content, Top Content report and filter by your virtual page. If it's in there, then it's your goal tracking set up. If it's not in there, it's your virtual page tracking on the form itself.
HTH.

Resources