Analytics - Where do the parameters come from - url

Google Analytics provides me a list of called links of my website.
I wonder where these requests came from and what they effect.
e.g.
www.mywebsite.com/subpage/?ls=1
www.mywebsite.com/subpage/?q=keyword
www.mywebsite.com/subpage/?q=13123sdd
What does ?ls=1 and ?q=keyworddo? And where do they came from? Especially the keywords

Those are GET parameters, and most commonly they come as a result of posting forms (or just by clicking on links with such URLs).
For (the most well-known) example, if you go to https://www.google.com and enter "test" and press Enter, you will go to a page http://google.com/search?q=test (with likely a bunch of other parameters as well). In a very simplified scenario, it would be because the box where you input your search string is an input element with name="q" contained in a form element with method="GET" action="/search"; when you submit the form (by pressing Enter), the browser will make the url by adding all the parameter to the form's action like this:
action?param1=value1&param2=value2...
or in this case, /search?q=test.
(In Google's specific case, this is not actually what is happening, because of various kinds of JavaScript magic that is normally going on; but that magic in the end does the same thing. But it could: if you turned off JavaScript on Google, then what I described would be exactly what would happen.)
As I said, you can submit that same URL literally, without having to go through a form. For example, you can click directly on this link to find some kittens: https://google.com/search?q=kittens
Parameters submitted with other methods than GET do not appear in URLs, and cannot be submitted merely by clicking a link, only through forms (which also support POST method) or JavaScript (which can submit any kind of method: GET, POST, or other methods not available to forms or links, like PUT, DELETE...)
As to what they do, nothing by themselves. They are interpreted by the www.mywebsite.com server, in any way they want. In Google's case, q is the query to search from, and what they do is give you (hopefully) relevant results to it. In www.mywebsite.com's case? No idea. Could be anything.

Related

Get Parameters of Link Clicked jQuery Mobile

I've been looking to find a way to get the url parameters of the link that was clicked in my pagebeforeshow event
$(document).on('pagebeforeshow', '#category',function(e,data){
})
With the link looking like this (you can also see I added a data attribute)
Dairy
I've read a bunch of different answers on here and tried lots of them, but I've discovered that they are looking to use the current url of the page to get the parameters. However the current page url does not have the parameters in it (as I'm using pagebeforeshow)
And then I've seen other examples where people are manually changing pages using jQuery.mobile.changePage but to me it seems like overkill having to add click listeners to my buttons and then manually pass in parameters using changePage for each of them
I have also looked at this plugin which probably would work, but I am reluctant to use a plugin for something which to me seems so simple
I just need to be able to access the url or the data-cat attribute that was clicked, but I can't seem to find an efficient way to do it without having to a click listener and then manually changing the page, surely there's a better way?
Update: jQuery Mobile 1.4.2

How to have a link that does not overwrite the URL

I have a link that I typically would have href="#". I would like the url to stay the same when it is clicked, but it seems like backbone copies and pastes the link to the URL no matter what it is. I even put
<a href="javascript:alert('true')>Link</a>
and the browsers URL was "localhost:5000/javascript:alert('true').
How can I get backbone to refrain from copy and pasting the link to the broswers URL
This is one of those "it's a feature not a bug" type of things. Backbone does that on purpose, for (at least) two reasons:
it gives a URL that users can copy/paste, email to each other, etc. and still take them to the correct place in your site; without such URL manipulation that's impossible
it allows for browser-based back/forward functionality (in browsers that don't yet support the history API)
There's probably other reasons too, but that's all I can think of at the moment. The point is, this is what the Backbone router is supposed to do. Using it, and then wondering how to make it not manipulate the URL is somewhat akin to using an <span> on the page and asking how to get let the user edit its text.
If you don't want that functionality, don't use the Router at all; just have your views invoke each other.

Submit webform via URL only?

I'm not really sure this belongs here, so instead of downvoting just lemme know if so and I'll quickly move it on.
Anyway, there is a website that has a search page, that when hitting the search button it doesn't include the search query in the URL.
After searching for something, the page is redirected to ssearch.asp, but as said, the query isn't there.
My question is if there is a way to submit the search values solely via URL.
I was wondering if there is a way to fake the search-submit button and post the search term
via URL according to form field names.
The name of the input box is search, so I tried this URL: http://www.torec.net/ssearch.asp?search=query, but it doesn't work, the server returns:
server error.
Just to be clear, I'm not looking for a server-side solution, and actually nor for a HTML solution, I just want to be able to paste a plain old URL in my browsers address bar and be there.
Is this possible?
Update
This link doesn't work:
http://www.torec.net/ssearch.asp?search=dark&page=1
While this one does:
http://www.torec.net/ssearch.asp?search=dark&page=2
Any way to bypass this?
Sometimes servers conflate GET and POST parameters, as in PHP $_REQUEST hash. However, normally they are separate - and a server that expects its parameters in multipart/form-data might not look at URL at all. In such a case, as it seems to be here, you have to construct a POST request. On the client side you can do it through AJAX or through constructing and posting a form; on the server side, you can use curl, or a library. You did not say what you want to use it for (and where you want to use it), so you just get the general answer, I'm afraid.
EDIT: Here is the JavaScript semi-solution. You have to already be on some page (i.e. can't use it on _blank), and I'm not sure if it works on all browsers.
javascript:d=document;f=d.createElement("form");h=d.createElement("input");f.setAttribute("method","post");f.setAttribute("enctype","application/x-www-form-urlencoded");f.setAttribute("action","http://www.torec.net/ssearch.asp");h.setAttribute("type","hidden");h.setAttribute("name","search");h.setAttribute("value","query");f.appendChild(h);d.body.appendChild(f);f.submit();
Edit: It is not possible to create a link directly to the first page. However, you can easily send a user to the first page by by creating a form:
<form id="postForm" method="post" action="http://www.example.com/search">
<input type="text" name="search" value="q">
</form>
And then submitting the form whenever the user clicks a psuedo-link:
document.getElementById("postForm").submit();
This can also be done by typing JavaScript code into the address bar:
javascript:a=document.createElement("form");a.method="POST";a.action="http://www.torec.net/‌​ssearch.asp?search=dark&page=2";i=document.createElement("input");i.name="search";i.value="q";a.appendChild(inpu‌​t);a.submit();

ajax request changing url

I have a pager on a table using ajax and I would like each such request also to change the browser's url, so when I hit refresh button I won't skip back to first page. I was fighting the Url parameter of AjaxOptions, but it keeps winning over me. Please help.
Trim
You can safely change the URL past the hash mark without redirecting the page. However, the user can (in most browsers) navigate through these changes with the Back and Forwards buttons. This technique is usually called "history."
Because the technique is difficult to get working in all browsers, you'll want to use a framework. Take a look at http://www.mikage.to/jquery/jquery_history.html.
I can also recommend ExtJS's history stuff too. Take a look at this example:
http://www.extjs.com/deploy/dev/examples/history/history.html#main-tabs:tab2
Again, notice that not only does the URL change when the user does stuff, but changing the URL (via Back and Forward) also affects the page. This is good, awesome even, but means it must be done very carefully.
There is not really a quick and easy way to do this, here is an article on the topic. The problem is that not only does the Ajax have to generate the URLs, it also has to take those URLs into account when loading the page to get the appropriate content.

Why would I put ?src= in a link?

I feel dumb for not knowing this, but I see a lot of links in web pages and instead of this:
<a href="http://foo.com/">
...they use this:
<a href="http://foo.com/?src=bar.com">
Now I understand that the ?src= is telling something that this referral is coming from bar.com, but I don't understand why this needs to be called out explicitly. Can anyone shed some light on it for me? Is this something I need to include in my program generated links?
EDIT: Ok, sorry, I'm not being clear enough. I understand the GET syntax with a question mark and parameters separated by ampersands. I'm wondering what's this special src parameter? Why would one site link to another and tack an src parameter on the end even though there's no indication that the destination site uses this normally.
For example, on this page hover your mouse over the screenshot. The link URL is http://moms4mom.com/?src=stackexchangesites
But moms4mom.com is our site. Passing the src parameter does nothing, so why include it?
There are a few reasons that the src is being used explicitly. But in general, it is easier and more reliable to trust a query string to determine referer[sic] than it is to trust the referer, since the latter is often broken, deliberately or not. On the other hand, browsers almost never break the query string in a url, since this, unlike referers, is pretty important for pages to function. Besides, a referer is often done without any deliberate action on the part of the site doing the refering, which some users dislike.
The reason (I do it) is that popular analytics tools sometimes make it easier to filter on query strings than referrers.
There is no standard to the src parameter. Each site has its own and it's usually up to the site that gets the link to define how it wants to read it (as usually it's that site that's going to pay for the click).
The second is a dynamic link, it's a URL that another language(like ASP and PHP) interpret as something to do, like in those Google URLs, but i never used this site(foo.com), then i don't much things about this parameter.
Depending on how the site processes its URL, you may or may not need to include the ?... information.
This is passed to the website, and the server can process it just like form input. Some sites require this - and build their navigation off a single page, using nothing but the "extra" stuff passed afterwards. If you're generating a link to a site like that, it will be required.
In other cases, this is just used to pass extra, unrequired info (such as advertising, tracking info, etc)... In those cases, you can leave it off.
Unfortunately, there's no way to know without trying whether you can remove the "extra" bits from the URL.
After reading some of your comments - I'll also say:
There is nothing special about the "src" field in a query string. The server is free to use it any way it wishes. Unless you know specific info about the server, you cannot assume it can be left out.
The part after the ? is the query string. Different sites use it for different things, and it is usually used for passing information to the server side code for that URL, but can also be used in javascript.
For more info see Query String

Resources