Posts tagged Google

Javascript – JQuery – Google Analytics – Submit Form Using GET Instead of POST

0

Was working on adding Google Analytics cross domain tracking for a form which uses the GET (instead of POST) method. The problem I was running into was the Google Analytics Tracking Cookie (GATC) data was not being added to the url, because the form’s data was overriding Google’s data. And I couldn’t switch the GET to a POST due to some low level and multiple redirect issues which occurred within the actions script. So I did some Googling around and came across some code snippets which I ended up implementing for my final solution, and wanted to share with you, in case you run into the same issue.

$(document).ready(function() {
    $('#formId').submit(function(e) {

        try {

            e.preventDefault();

            var form = this;

            if (typeof _gat !== 'undefined') {

                _gaq.push(['_linkByPost', this]);

                var pageTracker = _gat._getTrackerByName();

                var url = pageTracker._getLinkerUrl(form.action);

                var match = url.match(/[^=&?]+\s*=\s*[^&#]*/g);

                for ( var i = match.length; i--; ) {

                    var spl = match[i].split("=");

                    var name = spl[0].replace("[]", "");

                    var value = spl[1];

                    $('<input>').attr({
                        type: 'hidden',
                        name: name,
                        value: value
                    }).appendTo(form);
                }
            }

            setTimeout(function() { form.submit(); }, 400);
        } catch (e) { form.submit(); }
    });
});

Notice, that with the above snippet we can localize the GATC values that Google was going to append to the URL via POST, then convert them into hidden fields, linked to the form being submitted. So when the form is submitted the hidden values, along with the form’s organic values will all now be part of the URL and available to the form action.

General Category

General – Google New Privacy Policies Start Enforcement Today

0

If you haven’t heard, Google will start enforcing their new privacy policies starting today (3.1.2012). From what I have read and heard, they are basically consolidating logging of usage of all of their services into one area. So if you have your web based gmail account open, and do a search through Google maps or Google search, they will be able to log this activity into one folder, representing you. It has been said that if you are not logged into any Google based services, that the best they can do is track your activity through your IP address. Also, it has been said that Google will “guess” the names of your contacts if you type a name into one of their services. For example, if you are typing in Google docs, the name of a contact and mis-spell their name, Google will attempt to auto-correct based off your contact list. Scary.

Personally, I don’t agree with these overly invasive privacy policies and will be looking to ways of abstracting my activities as much as possible, which includes; not using Google Chrome any more, switching from web based Gmail to IMAP client, and using a different search engine. It’s not that I have anything to hide, but this “big brother” approach in efforts of increasing revenues based off my activities has gone way past acceptable limits.

News – Google SEO Processes

0

Pretty cool breakdown of the assumed processes that take place for Google’s search engine results. A lot of good information in the graphic which may help increase the SEO on your own projects (plus some other cool info about Google in general).

http://i.imgur.com/QMYuK.jpg

Go to Top