My client has a single page website and want each click on the main menu for a site area count as a pageview in Google Analytics. Is this possible? I advised him to use events.
Yes, call _trackPageview in JavaScript.
_trackPageview()
_trackPageview(opt_pageURL)
Main logic for GATC (Google Analytic Tracker Code). If linker functionalities are enabled, it attempts to extract cookie values from the URL. Otherwise, it tries to extract cookie values from document.cookie. It also updates or creates cookies as necessary, then writes them back to the document object. Gathers all the appropriate metrics to send to the UCFE (Urchin Collector Front-end).
Async Snippet (recommended)
https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiBasicConfiguration#_gat.GA_Tracker_._trackPageview
Related
I recently thought of a scenario and a solution for tracking user behavior with Google Tag Manager (GTM) and Google Analytics (GA). I wanted to get some feedback on the idea from other GTM and GA users in the community.
Scenario:
There may be an individual or company, who would like to know when a user completed a specified conversion path on their website; perhaps, they wanted to know which users visited a product description page, education page, and, then visited the store page, in that exact order.
There are many ways to capture that behavior. The solution that seemed best to me was to send a Custom Event (ex: "Path Complete") to GA by doing the following in GTM:
1 - Create a Custom HTML Tag in GTM that uses JavaScript to set/reset a tracking cookie on every PageView. This will read/increment/reset the cookie based on the built-in Page URL variable. The cookie value will increase with each step of the goal.
2 - Create a Custom JavaScript Variable to read the cookie value during every event.
3 - Create a Tag/Trigger in GTM that sends an Event when the user has performed the final step. The condition would be, for example, cookieValue=2 and store page link clicked.
This was shown to work on my own end. I was able to view the "Path Complete" in Google Analytics after testing and publishing the solution above.
Does anyone feel that this a bad way to do things or that there may be a more effective solution to the problem? Is it typically a bad practice to create Custom HTML tags that set/reset cookies?
I'm using Adobe DTM. What I'm trying to figure out is the best way to prevent the initial page load server call from going out on specific pages. The reason is, many parts of our website are 3rd party integrations separated by subdomains. Some of these 3rd party sites are Single Page Applications (SPA). Since most of our site is not a SPA, I need to figure out how to stop the initial server call when I hit one of these subdomains? The vendor is updating the s.pageName variable mapping on their end so I need to prevent the initial call from firing or I'll get two calls initially. I have a data element and event-based rule set-up to detect a change in the page name. I just need to stop it the first time.
Thanks!
In DTM, to prevent that default beacon on page load, you need to put a "return false" statement for those urls somewhere in your Adobe tool code. http://www.digitaldatatactics.com/examples/DCRsuppress.html has an example.
I had created a spreadsheet which alerts me whenever a stock price moves beyond a limit.
For alerts, I had integrated Pushbullet in the spreadsheet through the app script. But whenever I create a copy of that spreadsheet, I do not need to authorize the script to keep receiving alerts.
Though, I need to authorize the script if I run it from the Google App script inbuilt tool.
One more thing I discovered is that you need to compulsorily authorize the script if the triggers are manual but in my case the triggers are automated based on the price fluctuations so I don't need to authorize the code to keep running the scripts.
I also had a spreadsheet where I send emails by clicking a button and there I need to authorize the script.
Question: If the script is not authorized then why I'm still receiving alerts?
And what is the real reason behind authorizing the Google scripts?
Following is the link to the spreadsheet. You can also find the code for Pushbullet in the app script which is not authorized. And I'm still receiving the push notifications.
https://docs.google.com/spreadsheets/d/1HhvLDU_rTbYzDX7wY9TnZIarShxQJMJK8AHlUoEon7A
Create a copy and add your email associated with pushbullet to receive notifications on your device. Don't forget to change the boolean value to "Yes".
The reason behind authorization or reauthorizing of the Google app script is that, the script can be shared with multiple users and script has ability to access almost all Google apps data (e.g Gmail, Spreadsheet, Doc, Drive, Map etc.), which is / may be confidential information of that owner.
Therefore Owner must compile / run script first time and whenever there will be any service change then Owner must have to authenticate again.
Thanks.
I have a WordPress plugin which bloggers can opt-in for tracking. The data is used to improve the UX in yhe plugin's management dashboard settings pages.
Since we are only interested to track some button click events and don't really need the "pageviews" tracking, is there any way to tell Google to disable the pageviews tracking? I want to respect the publishers privacy as much as I can, and if there's no reason to track pageviews I would prefer to block it.
Disable pageview tracking
The default behavior of this snippet is to send a pageview hit to Google Analytics. This is the desired behavior in most cases; pageviews are automatically tracked once you add the snippet to each page on your site. However, if you don’t want the snippet to send a pageview hit to Google Analytics, set the send_page_view parameter to false:
gtag('config', 'GA_TRACKING_ID', { 'send_page_view': false });
From :https://developers.google.com/analytics/devguides/collection/gtagjs/#disable_page_view_tracking
You could do this with the Measurement Protocol directly. The Measurement protocol is just some HTTP posts or gets that send the data directly to your Google Analytics account. The JavaScript code that you get from Google basically does just that.
It is a little tricky there are some required fields you have to send or the data wont record correctly. But if all you want to be able to do is track some button clicks sending the events along shouldn't be to hard.
This is untested example:
http://www.google-analytics.com/collect?v=1&tid=UA-XXX-Y&cid=35009a79-1a05-49d7-b876-2b884d0f825b&t=event&ec=file&ea=upload&userclicked&ev=1
CID just needs to be a session id some way of knowing one user session from another.
NOTE: This will not record all of the normal data. you are going to loose things like language, location, pagepath. This is probably only going to store the event nothing else. I would consider putting it in its own web property to keep the data separate from any true Google Analytics recorded data.
I am trying to track goals firing using Google Analytics, and I am running into issues with tracking actual confirmation pages that are AJAX calls. The confirmation page isn't a URL exactly, but a .php file which is loaded in AJAX. I can't figure out for the life of me why goals aren't able to fire using an AJAX call, but I can easily track a URL.
Here is all the information I have regarding the goals, including the goals, and actual code and the landing page itself (https://docs.google.com/document/pub?id=1uUjX5wWOpy9w85fpocIz32gMIWvZSQzSG8WCBDSq4DA).
So, the URL that Google Analytics tracks is, by default, determined by what the browser detects (specifically, location.pathname+location.search). So, the filename of the php file that is loaded via AJAX is not relevant to Google Analytics, since by default, your trackPageview call will just send the URL that the browser shows (without the domain or anchor values).
Google Analytics allows you to pass a custom URL as the path, as the second parameter of trackPageview.
So, in your confirmation page, you need to switch the _gaq.push(['_trackPageview']); to be
_gaq.push(['_trackPageview', '/ed-JUNE-confirm']);
Now, there are other things that are confusing (for example, the multiple plain pageview calls on the same page), but, fundamentally, to 'trigger' the goal you need to send a pageview that has a head-match for your Goal URL, and use these virtual pageviews to accomplish it.