Google Analytics not tracking conversions in Magento 1.7 - magento

I'm using Magento's built in Googleanalytics module which is working fine for page views, but not for conversions. The account is set up fine on Google, but it's not adding the addTrans part in the checkout/onepage/success page.
I've done a lot of digging this morning, and found that the observer does observe the "checkout_onepage_controller_success_action" correctly, and does indeed run. It does the following:
$block = Mage::app()->getFrontController()->getAction()->getLayout()->getBlock('google_analytics');
if ($block) {
$block->setOrderIds($orderIds);
}
I've done some echoing, and it does retrieve the block, and it also sets the order ids correctly. However, in the block itself, if I echo out $this->getOrderIds(); its empty.
My next thought was that perhaps it could be using two GA blocks on the page, and maybe its passing the data to the first one but echoing the HTML of the 2nd one, but I've no clue how to start checking that! The Googleanalytics.xml file only has one block it in, and I don't use that block name anywhere else!
Anyone experienced similar? Or have any idea where I can go from here?
EDIT:
The Ga.php block includes the transaction code if $this->getOrderIds() returns an array, which it is not doing. However, the observer is doing $block->setOrderIds($order_ids); which is passing through an array containing an order id. So the observer is passing the ids to the block, and the block is receiving them (setting up a method of setBlockIds and echoing out the argument, does show the array), but when the block tries to access its own data, it's suddenly not there ($block->getData() returns an array of properties but there is no order_ids property).
I also figured maybe it could be that its echoing the blocks HTML before setting the order id, so I added some variables in to check that and it's not that - its definitely setting the order_ids before trying to get them again, but its still not working!
I'm completely stumped! My only idea now is to modify the Ga.php block to use Magento's registry instead of it's own _data property, which is really not a nice way of doing it!

I think i've been an utter tool. Magento wasn't tracking conversions on the live site because I hadn't put the account code in the configuration part, but I had on my test site.
I had previously put my own analytics code in the template, so I had tracked page views.
When I saw no conversions (despite putting the account code in my test site), I started making orders on the test site and then viewing the source of the order success page. Firefox loads its source as a new request...which automatically goes to the empty basket page. So obviously, it wasn't showing the addTrans or anything, because it had already done that.
A quick check in firebug revealled it was working as it should.
So in the end, after a day of searching, I had to change "No" to "Yes" in the admin, and type in the account code. Great.

Related

Magento store view redirects not working in 1.8.0.0

I have a store I'm developing that has two store views, one for each language I'm supporting. The products and categories have localized url keys.
In 1.7.0.2 my language switcher would redirect correctly (for ones that had "Create Permanent Redirect" as well as ones with out) but after upgrading to 1.8.0.0, it did not work any more.
Problem
There is a regression in 1.8.0.0, they updated Mage_Core_Controller_Varien_Front to use ::_getRequestRewriteController() in ::dispatch() previously it used Mage_Core_Model_Url_Rewrite and now it uses Mage_Core_Model_Url_Rewrite_Request
On line 143 of app/code/core/Mage/Core/Model/Url/Rewrite/Request.php it has $stores = $this->_app->getStores(); which returns an array of store_id index stores, but it goes on to check if the store it goes on to check with $fromStore, which is a variable from the GET params, ___from_store, which contains the store views key (e.g. default, french, etc), obviously this has problems looking up using a alpha key in a numericly index array.
Solution
The offending line is again, #143 in app/code/core/Mage/Core/Model/Url/Rewrite/Request.php, by simpling changing it to $stores = $this->_app->getStores(false, true) it will work, as the 2nd parameter being true (defaults to false) returns the array with store view codes as the array key.
Hope this helps someone, and if anyone knows the best way to pass this on to the Magento developers, I would appreciate it, as I said, the issue reporting just posted to the home page, which doesn't seem to work.
Edit: I would also like to point out as 1.8.1.0 this is still an issue.

How to alert Magento Site Admin about abandoned cart?

How could we alert a magento site admin about each abandoned cart immediately after it is abandoned?
Is it a default feature in Magento EE?
No it is not a default feature in Magento EE.
You ask how a site admin could be alerted of an event that is somewhat of a grey area.
Assuming that an abandon cart is defined by the following criteria (which in fact is not the definition but may be applicable to you)
A registered user (ignore guest users for sake of sanity here) has products in cart.
This user does not complete the checkout and leaves the store-front
A period of time goes by (eg 1 day) with no adjustments on the cart items
Assuming this situation is your abandoned cart scenario i could suggest the following :
1.) I would use the Magento Quote Object (this is the object that is converted to an order after a successful checkout.)
looking at the quote object there already seems like there are enough fields to be able to monitor when the quote was created, when it was updated, when it was converted and whether it was converted or not. If the object does not contain the data fields you need there is no reason why you could not extend it. See a sample snapshot :
My (naive) suggestion would be to set up a scheduled job, to run at the same frequency at which you define your "abandoned cart" scenairio (or any frequency for that matter).
The job could do something like the following :
1.) Instantiate a collection of quotes.
2.) Filter out quote's that have been converted
3.) Filter out quote's that have been created recently (less than the critria above)
4.) Filter out quote's that have been modified within the same time-frame criteria
at this point you should have a list of all quote's that have been created, perhaps been updated but not converted for the last 24hours (depending on your criteria of course).
If you get to this point, well then the rest is straight forward.
Extract the information you need from the quotes (id's names, numbers, emails etc), compile your report and email to the administrator.
it the best idea i can think of for now! i have not done this in practice...
Ofcourse you can set-up funnels and goals with Google Analytic to give you extensive information on your customers, including abandoned carts, but that doesn't answer your question.

How to make wp plugin auto-refreshing on the public side of view (auto load page)

First have to say that almost every time when searching on technical solutions.. search engine will direct me to this site here. I admit that i have learned such A LOT here just by searching through for answers..
but also have to say that not being a coder.. so don't understand much here at all ;)
Ok, the Problem:
Want to update wordpress tables or calendar within wp admin. These changes should become updated on the public side automatically and more or less instantly (~ few seconds is perfectly fine).
I found solutions about manipulating header.php, i found some ajax plugins I found -too much to count- info on how to implement ajax into wp
Sadly.. none of these could help me through as the plugins mostly either not work, are outdated or require countless file edits. Manipulating header.php seems odd.. as i don't want to loop-refresh the whole page, post etc.. but only get e.g. table or calendar data updated.
So maybe any of you coders know of something to e.g. get the plugin "All-in-One Event Calendar by Timely" to update the public visible part of the calendar once data edited in wp admin?
Greatly appreciate pointers in any direction to solve this.
P.S.: What would you think of plugins like "ajaxify everything" ? don't know if this really the way to go..
Again, thanks for your help, time and contribution!!
update
additional question:
I now found such plugin to let me chose which parts i want to "ajaxify".
Such plugin would ask me for a specific function name.
Now, where do i start to gather this information?
Below is the instruction from the plugin context inside wordpress admin
Generate Ajaxized DIV for your function
Ajaxize will allow you to ajaxize almost any php function on your
site.
It can be a plugin, a function you wrote, or even a core wordpress
function.
There are some (obvious or less obvious) limitations currently:
Functions must return valid HTML - this will be called in php and returned via the
Ajax call
Functions cannot accept any parameters (at least at the moment)
Enter a function name below.
Function Name: xxx input field xxx what put in here? xxx
The generated div can be inserted to any page/post on the site and
will ajaxize the call to the function automatically.
Please make sure you enter a valid function name, that the function
does not require any parameters, and that it returns valid HTML.
In your context you want to refresh the calendar automaticaly when there is a change in the WP_Admin;
but you can't exactly do this.
You can write a Js method which will check the time of lastest modification of the calendar at the load of the page, stock it in Var.
After you'll have a constant (each 10seconds) Js "daemon" which will get the time of lastest modification of the calendar and compare it to the stocked Var; If change you reload the calendar.
PS: Ajaxify everything is not really a solution due of the developpement you need To Ajaxify and to code for people who has disabled Javascript.
Hope it helps

Magento - getTreeHtml() - where on earth is this method?

Hopefully somebody can help me with this one as I'm a bit confused.
I'm trying to reverse engineer the product chooser widget so that I can trigger it off a button in the front end. I'm making progress, albeit slow.
One thing that is confusing me though is one of the lines of code in the container.phtml file:
getTreeHtml() ?>
I just cant seem to see where this 'getTreeHtml' method is. I've looked in the template's associated block, the block that that inherits from, and all the way up the object hierarchy. I've also done a text search on the whole of the Magento directory but this method doesnt appear anywhere... Am I missing something here?
Grateful for any help,
Ian
Its a non-declared field accessor (a 'magic' method). Whenever you call a setField(value) or getField() on a Varien_Object without really declaring this methods (they don't exist in the class), Varien_Object checks its $this->data array for a entry with a 'field' key. If such an entry exists it returns/sets the $this->data['field'] value.
The method is used in your Widget. Check out the file:
./Mage/Adminhtml/controllers/Catalog/Product/WidgetController.php:
Somewhere in it you can find this call:
setTreeHtml($categoriesTree->toHtml())
As you can see, the value is set in the controller, and later can be read in the template.

How can I view information about a variable or array in symfony 1.4

I am trying to learn symfony framework by creating a small project.
Since I started developing the project I have been wondering if there is a convenience function to see the contents or information of a variable or array anywherea in the application by print_r or echo or var_dump (I can use the aforesaid function straight away anywhere in the application but the output is not properly readable in case of large arrays, moreover there are warnings showin like header already sent etc. etc.).
I have also used cakePHP and it has a convenience function named pr() which prints out the contents of variable or array nicely indented (properly readable).
If I had to create such function than how can I make sure that it can be called anywhere in the application?
Any tips (links/blogs/tutorials) related to "how to debug your symfony applications" are greatly appreciated.
To put it simple: you can't output debug "things" in your controller. The controller has nothing to do with the View (output), so when executing it does not know if there's going to be any output.
But, you can output debug "things" in your controller ;-)...
Just print_r() or var_dump(). And immediately die afterwards. That way you can see your debugging.
Call the logger. $this->getLogger()->debug($message);
Add a custom slot which you assign in your controller ($this->getResponse()->setSlot('debug', $debugData)). And include this slot somewhere in your layout file (preferably only in the dev environment.)

Resources