In Magento 2 I am attempting to setup a controller I can retrieve after page load via Ajax that does not register as a URL in the admin panel for "Customers>Now Online"

I have a route.xml setup as

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="..
    <router id="standard">
        <route id="mymodule" frontName="mymodule">
            <module name="Testing_Mymodule" />

And a controller such as:

namespace Testing\Mymodule\Controller\Index;

class Index extends \Magento\Framework\App\Action\Action

    public function execute()
        $jsonData = json_encode(array('test1', 'test2', 'test3'));
        $this->getResponse()->setHeader('Content-type', 'application/json');

This results in a json result of the json array. Now if one checks the "Customers>Now Online" It shows the controller as the last URL visited. Is there a way to access this controller without registering the URL.

  • do you have a module.xml in your module? Did you clear the cache? How are you calling your url?
    – Marius
    Commented Aug 21, 2015 at 6:14
  • Marius, yes the module is appearing and I can connect to the controller. What I am trying to achieve is a controller that I can connect to via Ajax that doesn't change the customers "Now Online" URL
    – Eirik
    Commented Aug 21, 2015 at 15:03
  • I can access the controller via the domain.com/mymodule and it returns that json array. However, it is registering this as the last visited page for the customer in the "Customers>Now Online" report
    – Eirik
    Commented Aug 21, 2015 at 15:04

1 Answer 1


I took a look through the \Magento\Customer\Model\Visitor model and it seams that you can skip the loging for certain user agents and for certain modules. (check the initByRequest method).
By the looks of the method isModuleIgnored, the one that checks if a module should be skipped you may be able to ignore the logging for your module by adding this, in the di.xml of your module:

<type name="Magento\Customer\Model\Visitor">
        <argument name="ignores" xsi:type="array">
            <item name="the_route_name_of_your_module" xsi:type="bool">true</item>

But I didn't test it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.