I am using JavaScript to create a modal window when a user either clicks a link or submits a form. The modal window holds either a form if they click a link or a thank you page when a user submits a sign up form. The modal window is populated using innerHTML.
The issue I am having is that these modal windows have Google Analytic tags in their source code. For some odd reason the Google Analytics is not executing. I have tried to place the actual ga.js source into the pages, that didn't work. I have put the Analytics code in two separate files but that is not working either.
Any one ever ran into this issue? Any help would be greatly appreciated.
Don’t add script tags using .innerHTML. Just fire pageTracker._trackPageview() directly from javascript, as it is described in the Google Analytics API
Related
I'm developing a site (not mine) and I encountered a big trouble!
In this website I've got some modals that will open after a user clicks on a product, but I need to do so Google Bot detects these modals like pages. When a modal opens, a JS Function adds a # parameter to the URL like "#abc=modal_one".
I want that in Google Result appears this page as "www.test.com/page.php?#abc=modal_one". I've tried (and I'm trying) to render the page like Google Bot in Google Search Console, but GSC opens only the page and not the modal. I also added a ES6 (JS) code that just edits the page title when the modal is showing to the user (after user clicks to open the modal) but nothing, Google does not detect the page title set after the page is loaded.
If you can't understand something just tell me and I will try to explain my trouble newly.
Thanks in advance to all the StackOverflow community :)
Try exporting the various pages to a dynamic sitemap that Google can read.
View the Categorize parameters with the URL Parameters tool page for more information.
I am a newbie to extensions. i want to create a extension, when clicked on the icon it should open up the www.gmail.com, input my user name and password and login automatically,click on the first mail. Your help is highly appreciated. I tried many things like chrome inject api but did't work out.
Like said in comments, go have a look to documentation sample codes, it's a good start.
For your extension you should do something like this :
Open a tab with the gmail.com url.
in the callback, inject a content script in the newly created tab
In the content script put the login and the password in page input and then simulate a submit button click.
Try to do this for a first try. When you get it work, You can try to open the latest email received. Look for tabs and runtime message api to send data or event between injected scripts and background script.
I have a website where pages are loaded via AJAX so I reload the Facebook comments box and like button (FB.XFBML.parse()) each time a link is opened. I was wondering if there is a similar way to reload the Google Plus button with JavaScript for a page.
Parsetags should be set to explicit.
See: https://developers.google.com/+/plugins/+1button/
Then you can call gapi.plusone.go(); to have the tags re-parsed.
I have a page with 24 links that each open up a .html file in a modal window with Fancybox, and each .html file has a video embedded in it. How do I track to see who is opening which videos?
How google analytics works
You put a by Google provided javascript (the tracking code) on your page .
Everytime the page is loaded, the javascript is executed and a hit is recorded by Google.
How fancybox works
You can use fancybox in different ways but the default behaviour is that you feed it a link and it will open the content of this link inside an iframe
If you know how iframes work, you should know that they just load/display a page inside a page. But because they load an entire page, the by google provided javascript will also load.
Answer
So to finally answer your question...,
If you use fancybox by default (loading content inside an iframe) google analytics will already record the clicks on those pages.
If not you should check out the note below.
Note: This is how it works with the original Google Analytics tracking code. If you are using the new Asynchronous tracking you should really check out this page as it explains in detail how to hook custom events etc: http://code.google.com/intl/nl-NL/apis/analytics/docs/tracking/asyncUsageGuide.html
Using javascript (jQuery to be precise in my case) I need to enable a dialog box to be tracked in Google Analytics as a unique page view, despite it being only a modal overlay.
For context purposes I dont want the user leaving the page and the dialog content is loaded in via an ajax call.
Assuming you're using Google Analytics new async code, all you need to do is place this code in the JavaScript block where you render your modal dialog.
_gaq.push(['_trackPageview', '/fake/modal/path/here']);
If you're using the old code,
pageTracker._trackPageview('/fake/modal/path/here');
The basic gist of this is you should attach the _trackPageview call anywhere you're binding an event event that changes the modal. If you're doing this for multiple modal pageviews, you'll need to either manually code each internal modal page, or programmatically name them. If these modal changes trigger changes in the URL's hash, you could try this approach: Tracking Anchor Links in Goal Funnels
As per Google's documentation, ga.js is now a legacy library. So if you are using the latest version of this library, which is analytics.js, then the response would be:
ga('send', 'pageview', '/fake/modal/path/here');