0

When clicking on any site when clicking on a link with target="_blank" ... In the program, the page opens in the same window, but the Google Analytics counters see such a transition is not correct without a referrer. It seems like a direct approach. Tested with their sites also .. If in a normal browser I go with target="_blank" then the referrer is visible transition and displays the site from which the transition was. If I move from the program with the code shown here, it goes as a direct approach. Help to understand. Thank you!

class WebEnginePage(QWebEnginePage):

    def createWindow(self, _type):
        page = WebEnginePage(self)
        page.urlChanged.connect(self.on_url_changed)
        return page

    @pyqtSlot(QUrl)
    def on_url_changed(self, url):
        page = self.sender()
        self.setUrl(url)
        page.deleteLater()

class MainWindow(QMainWindow):
    def __init__(self, *args, **kwargs):
        super(MainWindow, self).__init__(*args, **kwargs)
        self.browser = QWebEngineView()
        page = WebEnginePage(self.browser)
        self.browser.setPage(page)
        self.browser.setUrl(QUrl("http://google.com"))
        self.browser.urlChanged.connect(self.update_urlbar)
        self.browser.loadFinished.connect(self.update_title)
        self.setCentralWidget(self.browser)
    def update_title(self):
        title = self.browser.page().title()
        self.setWindowTitle("%s - prog" % title)
    def update_urlbar(self, q):
        self.urlbar.setText(q.toString())
        self.urlbar.setCursorPosition(0)
yong
  • 3
  • 2
  • Could you give us an executable code? I can't connect `self.update_urlbar` and `update_title`. – Haru Apr 21 '19 at 14:06
  • You could explain how you are doing your test. On the other hand that trick I implemented in another post, visually you see that it opens on the same page but in reality it has opened in another window but as soon as you get the url I eliminate the window and open the new url in the initial window , maybe that explains what you see in Google Analytics. – eyllanesc Apr 21 '19 at 20:00
  • Added missing information – yong Apr 22 '19 at 08:11

0 Answers0