Tuesday, February 24, 2015

Universal Google Analytics Event Tracking Problems

I keep receiving a following error under Google GA Debugger plugin in Chrome:

Command ignored. Unknown target: undefined

In Google Analytics (GA) I do not see any events. I am using Universal Google Analytics and I attached it to a page thru Google Tag Manager (GTM).
When I change in GTM Tag Type from Universal Anaytics to Custom HTML Tag and paste manually GA code everything works.

Solution to the problem is to set a Tracker Name in GTM config

and raise events in a following way (Tracker Name is set to internalTrackerName):
ga('internalTrackerName.send', 'event', 'button', 'click', 'View Bookings');

Saturday, February 21, 2015

Python after years

Recently I've been installing python on Windows. I haven't done it for few years now. I was surprised that msi installer by default installs pip with its dependencies. It also comes with a basic IDE. This is really nice. Pip seams to be a standard now. But definitely there are few things that didn't change. A quick look at Django code:

def b85decode(b):
        _b85dec = [None] * 256
        for i, c in enumerate(iterbytes(_b85alphabet)):
            _b85dec[c] = i

        padding = (-len(b)) % 5
        b = b + b'~' * padding
        out = []
        packI = struct.Struct('!I').pack
        for i in range(0, len(b), 5):
            chunk = b[i:i + 5]
            acc = 0
            try:
                for c in iterbytes(chunk):
                    acc = acc * 85 + _b85dec[c]
            except TypeError:
                for j, c in enumerate(iterbytes(chunk)):
                    if _b85dec[c] is None:
                        raise ValueError(
                            'bad base85 character at position %d' % (i + j)
                        )
                raise
            try:
                out.append(packI(acc))
            except struct.error:
                raise ValueError('base85 overflow in hunk starting at byte %d'
                                 % i)

Ech, not much changed since I was looking at python programming style years ago. Its not language fault, it is more about how well people are writing open source code. How much does it take to understand what a method above is doing - the method name is a great help, but to understand implementation takes more than few minutes, and it is far more time than few seconds.