I have a flash file and am using google's suggested method for as2 event tracking like so:
getURL("javascript:pageTracker._trackEvent('Refferal', 'Join', 'Benefits for HCAs/APs');");
The problem is that instead of silently communicating, pageTracker._trackEvent() appears to return a boolean value. Every time I click the button which this is located on I leave the page I was on and end up on a page that just contains the word "true".
Does anyone know how to get around this? It makes the flash unusable.
If your flash is embedded in a web page, you could call a javascript function and let it handle the call to analytics using an external interface:
ExternalInterface.call("myJavaScriptFunction", parameter1, parameter2); (http://geekswithblogs.net/Mikeymac/archive/2006/03/13/72170.aspx)
Related
This may seem like a simple question, but it doesn't seem to be answered anywhere that i can find.
I am writing an onClick event handler that simply calls dataLayer.push() when an anchor is clicked.
Is dataLayer.push() a synchronous operation?
Will the GET request to google definitely be sent, even though the browser has unloaded the page it was requested from due to the link being followed?
Some browsers show the connection get cancelled, some show it success.
My question is if the computer is slow, is it possible for the page to get unloaded before the request is sent?
This is why i assume that google started using the eventCallback property to redirect the user after the link has been followed.
e.g.
https://developers.google.com/tag-manager/enhanced-ecommerce#product-clicks
This source code does not include the click handler, but implies that the onClick event should stop propogation and let the eventCallback function set document.location.
However, as soon as you cancel the event, all its information has gone.
This (in my opinion) is just the wrong way to do it.
e.g.
(CTRL or COMMAND) + Click opens a new tab on browsers. This will not work unless the onClick event handler allows the prorogation to continue.
Relying on eventCallback also means that if the google scrips didn't load for one of the many reasons it could (but is still unlikely), your links don't work. And your site is broken.
So this leaves the correct way to do it for the onClick event handler to allow the event to propagate and return true.
Which also means that dataLayer.push() would need return after the GET request was sent for any of this to work properly.
Code example:
NOTE: You will get mixed results in mixed environments.
Link
$(document).on('click', 'a', function(event) {
// Is dataLayer.push() guaranteed to fire a GET ?
// data set externally
dataLayer.push(data);
return true;
});
Is there anyone out there that can guarantee that the GET request will get fired to the google server?
Have the google developers forgotten something here?
EDIT: Updated title to be more relevant to the question.
datalayer.push does not send anything to Google. It pushes objects with key/value pairs to the datalayer array. This might contain an event which in turn fires a tag. Whether the tag is sent depends on the setup of the tag, not on the dataLayer.push.
As a consequence, when you write your own click handlers your are yourself responsible to make sure your tags are actually fired.
If you use the built-in click handler you can configure a delay to make sure your tag has time to fire before the link redirects:
Since link clicks usually cause the browser to load a new page and
interrupt any pending HTTP request, you have the option to add a small
delay to allow tags fired by Tag Manager to execute properly before
redirecting to the next page. Checking the “Wait For Tags” option will
delay opening of links until all tags have fired or the specified
timeout has elapsed, whichever comes first.
You should be able to mix both methods (push data on the click, but still use the "native" link click handler for the event).
You can also try to specify "beacon" as the transport method in your Google Analytics tags, on browsers that support this (which I think is only Chrome at the moment) GA will then use the navigator.sendBeacon interface, which sends the data even in case the page unloads.
You might think that Google's solution is not very elegant (but the simple delay has the advantage that it works for all tags, not just for GA), but they have not "forgotten" the problem.
Also solutions that combine GA hit callbacks with timeouts that redirects if the callback fails as proposed i.e. by Simo Ahava somewhere should be be doable with GTM, even if they are probably more cumbersome to implement in GA.
I am using the following eventListener to get certain output from gpt for each available slot
googletag.pubads().addEventListener('slotRenderEnded', function(event) {
gptForForm[count] = [ event.creativeId, event.lineItemId, event.size[0] + 'x' + event.size[1] ];
count++;
});
Now I want create an eventListener that will let me know when someone clicks on an ad, I tried the following to no avail
googletag.pubads().addEventListener('click', function(event) {
console.log('this lineItemID: '+event.lineItemID+', size: '+event.size[0]+','+event.size[0]+' clicked!!');
});";
I know I can get a report from DFP but we are trying to collect this data right away and real-time CTR and Clicks without having to check the report every single time. Are there any suggestions that I have not tried?
The short answer is - you can't (with JavaScript). There is no "click" action in the Google Publisher Tag (GPT).
Additionally, you can't set a click event on an iFrame without access to the DOM inside the iFrame. Unless you are using all friendly iFrames, you won't be able to.
Another (and likely better) option is to use the DFP API.
Another option is to set up your own redirection URL (http://example.com/path/to/dfp/redirector) that you would need to prepend to the URL the ad needs to redirect to (your redirector would register a click then redirect to the ad's URL). So you would need to add your redirection URL before the ad's URL in every creative you make in DFP (not even sure if this would be a violation of the DFP terms of service [TOS]). You would not be able to detect a click within the browser/client using JavaScript but it would allow you to register your own clicks in a server. This would require server resources on your part so make sure your hardware can handle registering the click and redirect quickly.
For the past few days I have been messing with the basics of tag management and "disassembling" the GTM code, trying to figure out how this thing really works. There is one thing I cannot figure out:
Scenario 1.
I hardcode dataLayer into the page html
I append JS code to page elements that I wish to "tag" and push their events into the DL (pdf download, onClick=....)
in GTM interface I create a tag which handles this onClick event and retrieves value pushed into the DL
It works like this:
When pdf download is clicked, object is pushed into the DL
tag fires and retrieves the event value
sends it to the GA servers -> all clear here
Scenario 2.
I DON'T create dataLayer on the page; GTM code snippet creates one upon loading the page in the browser
HERE comes the missing link: since I haven't coded DL into the page, I probably haven't appended the .push() method to the appropriate DOM elements as well
Question:
Can this somehow be done via GTM interface? If yes, this means that I can somehow "inject" extra JS code into my page code after the page has loaded in the browser?
Cheers!
EDIT (after more education):
It seems that it is possible to do a lot. GTM checks if there is a datalayer on the page and if it cannot find one, it creates it for you. Uou then set up macros to push objects into this DL (events) and finally, you can have tags retrieve information from the DL and send it to the Google analytics. Am I right?
You could create your own "DataLayer" by creating a dedicated tag declarating an array but this personal DataLayer could not be use in triggers.
To cover that, you can use another tag with a test (if array contains X then function ...), but I could not see how that is better than your scenario 1. If you do that, be sure to use tag priorities so the first tag is triggerred first.
You can use built in Universal Analytics Event tag to track .pdf downloads without dataLayer hard codding.
If you want to fire tags after page has loaded you can use "event equals gtm.load" condition in firing trigger. For example, you can use it to fire customer HTML tag with any kind of Javascript code.
I want to write an Google Chrome extension to prevent a specific webpage to react on blur events.
I know how to do it for the javascript part : I inject some javascript in the page at runtime:"document_start" in order to overload the addEventListener method with my own function.
The problem is with flash parts on the page. Theses can use addEventListener(flash.events.Event.DEACTIVATE,deactivate_method_in_as3);
Of course I'd like to prevent the method call
So I have several questions :
Is it possible to set a security parameter somewhere to disallow Chrome to transmit focus related events to the application ?
Is it possible to modify 'on the fly' the swf file to remove or overide this handler (of course I have no control on that swf).
I also started to use the chrome.debugger.* and chrome.windows.* APIs because they can intercept events early. In that case I have a annoying message saying "tab is debugged by ..."
The swf has a similar handler for flash.events.Event.ACTIVATE so I can try to use it. But how to trigger it when the page is not focused ? (I tried to call focus() on it but it doesnt seems to work.
Any other idea welcome :)
Thanks for reading
We have a site that uses both Omniture and Google Analytics. Ideally, we want to report in both suites on clicks to outbound links.
I'd like to do this the "right way," i.e. overcoming the race condition that occurs when requesting a site and the tracking pixel at the same time. See: http://www.gwotricks.com/test/2009/07/tracking-outbound-links-right-way.html
I probably wouldn't use the "onclick" attribute, instead binding the trackEvent to the link's click event.
Omniture's external link tracking overcomes the condition by hooking a 500ms delay into s.tl():
www. webmetric.org/white_paper/link_tracking.pdf
Has anyone tried doing both on the same site? Ideally I'd like to call both tracking pixels with an appropriate amount of time before the page executes, but I'm not a big enough Omniture buff to really have gone in-depth with their code and hook trackEvent in before the delay.
Use JavaScript DOM (or if you use it, jQuery) to bind the events and utilize the new asynchronous Google Analytics tracking code and you should be set.
Sample codes for JavaScript event binders are everywhere if you don't want to use jQuery.
Done this several times, never interfered and never had to use a timer.