Google Analytics Site Search - javascript

I use following sample URL pattern to search pattern on my web site.
http://www.mysite.com/search/someword
No query strings, just clean URL..
How can set this URL to google analytics site search system?

In theory, you should be able to create a profile filter to convert the URLs to use a query string. In practice, it turns out it's not possible, because Site Search gets processed before filters get processed.
Instead, what I've found that works is to just manipulate it in JavaScript so that you "fake" a query string directly from the browser.
Something like:
if(!location.pathname.match(/^\/search/)){
_gaq.push(["_trackPageview"]);
}
else{
_gaq.push(["_trackPageview", location.pathname.replace("/search/","/search?q=")]);
}
This would "fake" a query string with a key of q that you could then easily use the Site Search feature with.

Related

How to get number of instagram posts in specific location and with specific tag

I looked at the Instagram API (maybe not efficiently, who knows?) but I didn't find a way to use a kind of REST API allowing the search of the number of posts in a specific location and with a specific hashtag.
I don't care about the pictures themself, my goal is, with a kind of filter like: 'specific location : FRANCE' & 'hashtag : Beach', to get a list of public posts (here, all the posts in France where the hashtag Beach has been used) with :
- accurated location (city or lat/lon)
- tags
- timestamp
In the Instagram API the technologies allowed are Ruby, Python and PHP but I juste want a way to use it though a request in JS/TS and put a clustering of the result on a map !
Not sure if it's possible but in the app it is (with hashtags only) so if you've got a clue, please, give it to me ! =)
Thanks a lot !
Instagram has deprecated their old REST API source and replaced it with a Facebook-like Graph API. In that Graph API, you can search for hashtags but you are limited to 30 unique hashtags in a rolling 7 day period. And even with the hashtag search, you are unable to get location data about the results. You might have luck looking at the results and searching for specific text strings, but there is no longer anything like what you are looking for in the Instagram API, largely due to privacy concerns.

Bing Images search URL with disabled safe search

I'm trying to retrieve the web page content of Bing Images for a specific query.
I'm currently communicating with Bing through the following URL (in case of a sample foo search), from curl command line tool:
curl http://www.bing.com/images/search?q=foo
Since the safe search filter is enabled by default, I'd need to disable it.
How can I do that?
I know that direct API access would be preferable, but I need to bypass them and retrieve the entire web page.
I saw that from the web page, the safe search is disabled through Ajax calls.
What URL should I contact to make a search with safe search disabled?
The correct solution is to use the query parameter safeSearch=off, like
curl http://www.bing.com/images/search?q=foo&safeSearch=off
This is not documented anywhere I could find.
Add &adlt_set=off to the Bing Search url to close SafeSearch.
&adlt_set=moderate to filter adult images and videos but not text from your search results.
&adlt_set=Strict to filter out adult text, images, and videos from your search results.
The solution is simply to add &safesearch=off to the search URL.

How do I download 100 images using Google Custom Search API for use with Processing?

A friend and I are trying to create a Photomosaic generator in Processing. We want to be able to pull 100 images from Google using the Custom Search API, restricting the image size and dominant color, along with few other things. We want to save these images so that we can process them in our program. We also want to use data that will come from the GUI to be used to build the API call, i.e the search keyword.
The following code snippet shows what parameters we want to constrain our image search with:
var searcher = new google.search.customSearchControl.getImageSearcher();
searcher.setRestriction(
google.search.Search.RESTRICT_SAFESEARCH,
google.search.Search.SAFESEARCH_STRICT
);
searcher.setRestriction(
google.search.customSearchControl.getImageSearcher.RESTRICT_IMAGESIZE,
google.search.customSearchControl.getImageSearcher.IMAGESIZE_MEDUIM
);
searcher.setRestriction(
google.search.customSearchControl.getImageSearcher.RESTRICT_COLORFILTER,
google.search.customSearchControl.getImageSearcher.COLOR_RED
);
searcher.execute(keyword);
We just aren't sure how to restrict the number of search results or what format the data returns in. Is it JSON?
This is if you are building a URL, and not doing it programatically.
To specify JSON as the return value, append &alt=json to the end of your request URL.
To limit the number of searches returned, use num=50 as one of the parameters
Source: https://developers.google.com/custom-search/v1/using_rest#query-params
The following page has all the documentation for the Google custom search API:
https://developers.google.com/custom-search/v1/overview
At a first glance I can see it's a JSON / atom api. So I guess probably the default return format is JSON and through content negotation you can also request atom (but again, please read the documentation to be sure).

Take jobs from jobvite with javascript

Is there any way to take the list of available positions for a company from JobVite using javascript (I would prefer if it returned JSON)?
I would like to take 5 random open position and display them in a recruiting region on the website I am working on.
I can confirm that Jobvite DOES have an API, and it returns results in JSON! You need to submit a request to obtain an API key. (Look in the Category dropdown menu)
http://recruiting.jobvite.com/support/customer
Yes. You'll need an API key and secret as blastronaut points out. Then hit this URL:
https://api.jobvite.com/v1/jobFeed?api=KEY&sc=SECRET&companyId=COMPANYID
The API documentation is here: Jobvite Services API PDF
Well, if they have no API, I guess you're going to need to use cURL or something similar and then your PHP could return JSON encoded results?
Failing that, you might check out:
https://github.com/dylang/jobvite

Using Google Analytics without sending query string data

We're doing a simple implementation of Google Analytics on our ASP.NET with jQuery/AJAX web, and for most of it we just call _trackPageview and let Google do the rest.
We do a lot of data transfer in query strings, and recently, management became concerned that a lot of our data (such as product numbers) would be sent to Google. Without discussing whether that should be a concern:
Is it possible to use Google Analytics at all without sending the query string to Google's servers? I know how to filter it out from the actual reports, but I'm looking for a way to prevent it from being sent over the wire at all.
Yes, as Litso said, you can send a whatever you want as the pathname for a GA page-view, but you'll want to automate the process with JavaScript.
The following code will take the current URL's pathname (which excludes the query string) and uses it as the pagename value.
_gaq.push(['_trackPageview', location.pathname ]);
Or, conversely, if you're using the old _gat code,
pageTracker._trackPageview(location.pathname);
So, if your URL is http://example.com/path/to/page.html?supersecretinfo, it will get tracked in GA as /path/to/page.html
In stead of automatically tracking the pageview, you can use
pageTracker._trackPageview('/dir/example.html');
You'll have to dynamically strip out the parameters off of the url of each page. I'm not sure how to do that but it's definitely possible with JavaScript.

Categories