Event tracking and virtual pageviews are not tracked in Google Analytics - events

I'm trying to track how visitors interact with the price calculator that i placed on my website.
I've tried placing events and virtual pageviews in different places and events (onClick, onMouseDown, onMouseOver, in href attribute, onChange in the input tag). No matter what i do - no events or virtual pageviews are tracked, though i can see the __utm.gif requests for everything i want to track in FireBug, but nothing in GA reports.
Here's the calculator i'm tracking (it's in Russian, the event i'm trying to track is the big orange button).

Firstly, I do see a _trackPageview() call passing "/virtual/trees/calculate" on various onmouseover,onchange, and onclicks, and at face value I see no reason you shouldn't be seeing "/virtual/trees/calculate" show up in your pages report, but google officially states that it takes up to 24 hours to see data.
Second, I do not see any event tracking on your page. I do not see any code for it, nor do I see any GA calls showing it from random interactions on your page. If it is there, you will need to give detail about where it is and how it is coded.
Third, do you see the page view for the actual page? Which account/profile are you looking at? Because when I first load the page, I see two separate hits to GA happening, the first to account/profile # "UA-25026876-1" (which is from your on-page code) and the second to account/profile # "UA-20200270-1" (which is happening from a counter.js script include), and the second one is where your virtual page views are going to.

Related

Issues with State/Pages

I'm having an issue with my bot changing an unexpected page. For example, I have a sample application where you order a pizza. It goes like this:
"I want to order a pizza."
Pick your toppings
Pick your type of crust
Speak any special requests (light on the cheese, etc.)
I want to make sure that when the user is on a specific page that it won't jump back to a different page. If it asks me what type of crust I want on my pizza, and I say "pepperoni," it should trigger a "no match," but instead it jumps back to #2, assuming that I am picking my toppings. It shouldn't go back; the topping has already been chosen. With Dialogflow ES I could prevent this from happening by marking the intent with a specific context, but I don't know how to prevent that from happening in Dialogflow CX.
How do I keep the bot on the right path without the user being able to jump around the flow by saying something unexpected? Any help is appreciated.
You say that the issue you're describing only happens in the Start page. That happens because the Start page is not a real page at all.
I suggest you take a look at the documentation, specifically to scoping routes and handlers.
If you use the API, the Start page's routes and handlers actually represent the flow's routes and handlers. So if you specify a route (an intent or condition which maps to a transition) in the Start page, that route will be accessible from the whole flow. At any given point inside of a flow, any and all routes available in the Start page are also available (or in scope) in the following pages of the same flow.
To work around the issue I suggest you place a route in the start page which has a custom condition of true (will always occur when you're in the start page) and a transition to a "Start order" page. From this point use the builder as you've already done, build the next pages with the parameters and intents you're using. With this workaround, each page only allows the transitions specified in that specific page and you can restrict the intents available.

Dynamically change address in the URL bar

Okay, I have seem similar questions around Stack sites, yet some of them were asked as far back as four years ago, so given the recent developments in HTML, jQuery and PHP, I'm convinced there are new workarounds.
Suppose I have a domain www.mysite.co.uk, which has an ajax that, once triggered, clears the default on-load content #0, and replaces it with content #1.
(This content can also be accessed by going to www.mysite.co.uk/1)
Then a user may trigger another ajax that will clear content #1 and populate with content #2.
This is where I have a problem. Because clicking the Back button will not send the user back to content #1 (in fact if there is no history, the Back button is greyed out).
What I want to do, is when user triggers an ajax that populates the page with content #3, I also want it to change the URL bar to www.mysite.co.uk/3, so this way the same content will load when the page is refreshed, instead of going back to the default content #0.
Hope this makes sense.
I know that www.asana.com do it, but not sure how.
I'm already developing grey hair by trying to sort this out.
Edit: I've seen some examples where they do that by #anchoring, or with a ?get_variable, but I'd rather do it by changing the URL-proper, like Asana.com does it.
You're looking for JavaScript's pushState() method in the history API:
Manipulating the browser history
Note: you can check compatibility with browsers on Can I use...

detect if site is being accessed via iframe? embed widget with shopping cart

I have a shopping cart I want to embed in a widget/iframe on other users sites, I see three ways of doing this each with drawbacks. Here are options from estimated most to least work.
Recreate interactive shopping cart UI in javascript widget then pass values to server script with AJAX, variables are passed to the main site, when user clicks "checkout" the user is then redirected to main shopping cart site with variables populated from what the entered in the widget.
pros: complete experience
cons: most work to complete creating UI and AJAX request.
Somehow detect if user is coming to shopping cart via iframe, if this is the case have alternate code that opens new window when user clicks "checkout" redirecting user to secure page and getting variables from cart via AJAX to populate final checkout.
pros: mid amount of work, must do AJAX request to get variables from shopping cart to populate final checkout
cons: can we easily detect if site is being accessed from a user within an iframe on another site?
complete entire checkout process inside iframe/widget.
pros: least ammount of work, just embed cart in iframe
cons: will not show https in browser user may be reluctant to purchase
What is the best option?
If you could provide a bit more information, maybe I could offer you an even better option. For starters, what have you built this application with (languages/framework)? Also, would you say your application's functionality is similar to Shopify's in that you allow users to host e-commerce sites through your service? If not, tell us a bit more about your application.
Here's a quick response to the options you provided.
option 1: the only real option as I see it. Whether you're embedding the shopping cart in specifically an iframe or rendering it onto the user's page as part of a template, you should be navigating the customer away to your main site to complete the checkout process. Or at least give them a lot of screen real-estate to work with (a sizable modal for example).
option 2: is messy. You can tell if a request is coming from a remote form (like an iframe) by appending url parameters. But taking the approach you're suggesting with this doesn't make too much sense.
option 3: too heavy unless you take a modal-approach like what I mentioned in response to option 1.
That being said, if you are building an application like Shopify, you should be able to build a template for each user's website that has a section dedicated to displaying a shopping cart pertaining to the current customer's session. No iframes or widgets necessary with this approach. But again, it all depends on the use cases of your application.
If your only concern with Option 2 is detecting if your content is being loaded within an iframe, you can do that with JavaScript by using "top.frames.length" or "top === self."
For example, you could show or hide different conditional form content, or a different submit button, using the following:
if (top.frames.length == 0) {
// Show content if not embedded in an iframe.
document.getElementById('embedded-content').style.display = "none";
document.getElementById('unembedded-content').style.display = "block";
}
else {
// Show content if embedded in an iframe.
document.getElementById('embedded-content').style.display = "block";
document.getElementById('unembedded-content').style.display = "none";
}
As you've stated, the first option is the best in terms of user experience and the most likely to achieve the highest possible conversions. How much better the conversion is compared to the next best solution cannot be objectively measured, as it involves recurring customers, your own brand name, the kind of products, etc. Since the conversion rates will directly affect you (and your company), it's wise to make an estimate first to see if your efforts spent will be worth it in the short and long term.
The second option is the sweet middle ground; you still get brand recognition and customers will have some security reassurance (via address bar); (i)frame detection is easily done by a simple JavaScript comparison: top === window. However, you're losing the continuity and hence likely lose some conversion. If this risk is manageable, I'd go for this option in the short term.
Not being able to see the security certificate directly via the green lock makes the third option the least desirable. However, not all is lost; by clever use of imagery you can still gain some trust with your end-user, as outlined in this image, which is part of a great article from Smashing Magazine.
Your decision should be based on:
what can be done in the short term
what should be done in the long term
how important is secure visual cues to my potential customer
time / money spent on either solution versus revenues (break-even analysis)

Adsense revenue depending on use of Ajax

I noticed that a website like imgur.com displays ads on each page of the website.
This means each time you press "next" to view another funny picture, AdSense refreshes.
But a website where you can scroll to view more pages(such as 9gag.com),
Ajax handles loading of more funny pictures so it's illegal to refresh Adsense when a user scrolls for more funny pictures.
Does this means 50 users staying on 9gag.com for 3 hours scrolling and viewing 300 funny pictures would help 9gag.com generate revenue equal to ONE imgur.com user that views only 1 picture?
Does this also mean I should stay away from Ajax if I wanted revenue?
This was very confusing for me, please help me understand AdSense better.
Thank you!
WEll the problem with fully scripted ajax loaded content is that Adsense cannot read it. Therefore it has a hard time displaying relevant ads, because most advertisers have chosen to target the visitor location and the keywords on the pages. So if Adsense has no text, then most of the time it's not going to be able to serve an ad.
But I looked at 9gag.com and they are using what I think is the ajax version of Adsense, or perhaps the premium version of Adsense which allows for all sorts of things and is quite different from the core Adsense program in many ways that nobody seems to know about, and few are invited. All the big publishers I suppose.
Anyway, if you do end up clicking on one of the posts on 9gag.com you'll see other ads. Granted that the way that imgr.com has things set up should encourage more content viewing per visitor and thus also some more ad viewing, but I wouldn't say that one necessarily has more traffic overall than the other. There are too many unknown factors to determine that. Not something you can do just with looking at a site. That is where having good analytics of your traffic and visitor behavior comes in.

How do you prevent gaming of page views?

Say I have a site with pages. Pages are ranked based on the number of times they have been viewed. It is good for a page to be highly ranked because it will make it show up higher in my search results. Hence, the author of a page may try to game the system to increase that particular page's views.
So how do you prevent that while still keeping a quasi-accurate count?
I have come up with the following "scheme":
A user can only affect the page view once per session. This is what I would normally expect. If a user returns to the site later and views the page again, it should count as another page view.
The problem is that this makes the page view increment vulnerable to a script that clears its cookies before each request. The easiest solution to this problem would be to save the ip-address and only allow the same ip-address to increment page count once. This however has several major drawbacks; First of all, this would potentially take up a lot of storage, and second of all would prevent users on big LANs from incrementing page count. Lastly, a user cannot revisit a page and increment the page view more than once from the same ip. I can live with that, but would rather live without it.
The best method I can come up with off the top of my head would be to save the last X ip-addresses, and not let anyone from these ip-addresses affect the page view count. This would effectively stop any (simple) script from raising the page view count. Furthermore it would probably be a good idea to add a delay to the display of actual view count (basically keeping two counts and a datetime field for when the "display" count was last updated with the "actual" count, something I believe is done on the SE sites).
This is not a perfect solution, so I would be happy to hear your suggestions and/or comments.
Don't prevent: monitor and handle.
I would use a very different approach. Let the page views stay the same, but have reporting in place to looks for view-gaming. If a page gets gamed, you can find out who is responsible, give them a warning and a page-view penalty. If it continues, ban them.
I think that you should consider the reported characteristics of the browser as well. Browser fingerprinting has been done before and is well publicized. You can then figure out some pretty advanced heuristics on determining whether the same user is trying to game you. But don't publicize that you're using browser fingerprinting of course. Also, it won't stop incognito mode, but I'm just trying to give you one more avenue of thought to follow, in addition to your current IP oriented strategies.

Resources