Analytics firing on AJAX by default? - google-analytics

I am trying to get Google Analytics Site Search to work but our search is #-based and not ?-based, meaning the parameters are not being picked up.
I want to intercept the url sent to GA and replacing the # with ?, but I am surprised to see that our AJAX calls are already going to GA on every search. Where is this behaviour coming from - does GA automatically bind to AjaxComplete by default? How could I pull off my intercept then?

The update on AJAX call is being done by jQuery, not GA. Useful.
The workaround for my problem is to use an extra instruction with _setAllowAnchor, which instructs GA to treat # as ?.
https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiCampaignTracking
We found the solution here:
http://www.lunametrics.com/blog/2009/02/04/setallowanchor/

The other approach is to use the search and replace filter in Google Analytics.
jQuery address is rewriting the url /Search#reg=term to /Search/reg=term
We use the search string ^\/Search\/ with a replacement string as /Search?

Related

Will Google Analytics treat url parameter as part of URL?

I need to incorporate my own parameters as part of url. (e.g. #student=DD&start=Date1&end=Date2). However, I am cerncerning about if I add my part to the url, will it mess up my google analytics tracking? Basically, now my url is something like -- MywebsiteUrl?userID=AAA#student=DD&start=Date1&end=Date2&utm_source=CC....
What url Google analytics will track? is my website url -- MywebsiteUrl, or ``MywebsiteUrl?userID=AAA#student=DD&start=Date1&end=Date2`?
Thanks in advance!
Google Analytics will treat query parameters as part of the URL. However it will not treat #student=DD&start=Date1&end=Date2 as having query paramaters. As far as (native) Javascript and the GA tracking code is concerned the URL ends after the fragment identifier (#).
So your complete example
MywebsiteUrl?userID=AAA#student=DD&start=Date1&end=Date2&utm_source=CC
you will get MywebsiteUrl?userID=AAA. If the userID parameter contains personally identifiable information you need to remove it to conform to Google's terms of service. You can use a filter or the exclude parameters-box in the view settings.

Is there a way to remove the ga cookie id parameters after a ? mark in a page URL from Google Analtyics Reporting

We have an instance of cross-domain tracking within Google Analytics with a single sign-on between sites. The sites are on GTM. The single sign-on generates a Google Analytics id such as (?_ga=1.18339449.1954186898.1485354375) which are appended to the end of page URL's.
Our preference is that the id's do not appear within page level reporting as GA treats each page as unique which in turn increases the chances of sampling. We've been unable to use the "Exclude URL Query Parameters" feature found within the view settings to remove the parameters from page level reporting.
I could not find blog or stack overflow posts specifically stating how to remove the id parameters from within Google Analytics reporting.
Is there a suggested alternative to prevent the id parameters from being appended to the sites page URL's?
If you aren't able to use the Exclude URL Query Parameters option to strip the parameter from the URL...that stinks. You might want to let Google know the feature isn't working as expected.
Another option is to use an Advanced filter with regex to strip the parameter from the Page. You can do this with the following settings:
Field A: Request URI
Pattern: ^(.+)\?_ga
Output To -> Constructor
Request URI
Pattern: $A1
This is a quick and dirty filter that will strip off all query parameters when _ga is the first parameter shown.

Does Google Analytics Destination Goal Tracking match query params?

I'm investigating Google Analtyics Goal tracking. I would like to append a query param to specific urls to indicate goal completion. Eg.
/some/path?goal=goal_name
I do not want to use the path part of the url for matching, only the query param. If I setup a destination regex matcher, will Google Analytics match the param part of the url? Eg.
goal=goal_name
Yes, it does. If you use regexp as match type remember to escape your question mark if you use the full url (i.e. /some/path\?goal=goal_name).
You can actually test this easily - the realtime reports have a "conversion" menu item that shows goal conversions immediately (not e-commerce-transactions, though). I usually create a separate view to test new goals and filters so I don't mess up my live data - I recommend you do the same.

How to populate google analytics UTM variables manually

I want to be able to set the UTM variables manually
So instead of having a webpage
http://mysite.net/index.html?utm_source=source&utm_medium=inbound&utm_campaign=campname
I want to be able to set these with javascript. Looking through the documentation I couldn't find any set methods for these, only the set key methods.
https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCampaigns
I have also tried
_gaq.push(['_trackPageview', '/index.html?utm_source=source&utm_medium=inbound&utm_campaign=campname']);
Although as far as I can tell this doesn't work. The only way I can now see of getting this to work will be to set these using a hash value:
ie:
http://mysite.net/index.html#utm_source=In+House&utm_medium=email&utm_campaign=Fall+email+offers
_gaq.push(['_setAllowAnchor', true]);
Is there a better way?
edit
Actually it seems there IS a way to do this using GA code!
previous answer
I've needed to do this in the past as well and I could not find any way to do it on-page. I believe the only way you can really do this is by reading GA's __utmz cookie and rewriting the cookie with the value(s) you want.
example:
This is what __utmz would normally look like on if you go to www.mysite.com with no url params (the numbers in the cookie will be different):
URL: http://www.mysite.com
__utmz cookie value: 97566023.1329384140.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)
Here is what it would look like if you were to go to the URL with the values in the URL (the official way to do it):
URL: http://mysite.net/index.html?utm_source=In+House&utm_medium=email&utm_campaign=Fall+email+offers
__utmz cookie value: 97566023.1329384140.1.1.utmcsr=In House|utmccn=Fall email offers|utmcmd=email
And the cookie will have these values on subsequent page views, and you will see them sent to GA in the utmcc URL param in the request URL. So basically you can alter the __utmz cookie to the values you want. Would probably be more convenient to write a wrapper function to easily set it. Honestly, I don't know why GA doesn't provide a way to do this with a baked in wrapper function...

Is it possible to use a search string url with Google Calendar

Would any body know if it is possible to search calendar events with a url string?
For example with gMail you could use:
https://mail.google.com/mail/?shva=1#search/Search+Term
to search for the words 'search' and 'term'
Any help or advice greatly appreciated.
Cheers
Noel
This is how you can search Google Calendar using a query parameter in the url:
https://www.google.com/calendar/render?q=TERM
where TERM is the string you're searching for.
So, you can search using a GET request.
Using Chrome's dev tools, it appears as though Google Calendar searches are performed using a POST request, so you won't be able to pass search terms into urls to fetch a response (which would be a GET request).
Update: Looks like a GET request will still return results, but the response is some form of JSON.
Here is the url (I x'd out my specific info), looks like its not meant for what you want to use it for:
https://www.google.com/calendar/search?ctz=America/New_York&hl=en&as_tp=basic&as_myuids=xxx&as_otheruids=xxx&as_q=kai%20mallea&as_cal=xxx;xxx&secid=xxx
A generalization of the current answer is:
https://calendar.google.com/calendar/b/0/render?q=TERM
where 0 is the index of the desired Google account (if you have multiple accounts).

Resources