Google analytics duration zero for the pages visited by Selenium
<p>I want to visit a web site with Selenium and python like this:</p>

<pre><code>browser = webdriver.Firefox()
browser.get(url)
time.sleep(20)
browser.close()
</code></pre>

<p>When I check the duration in google analytic after an hour, I see the duratioin is zero.
I've change it to this code to click on a link in the page after 30 seconds:</p>

<pre><code>browser = webdriver.Firefox()
browser.get(url)
time.sleep(30)
elm = browser.find_element_by_xpath(link)
elm.send_keys(Keys.CONTROL + Keys.RETURN)
time.sleep(10)
browser.quit()
</code></pre>

<p>But nothing has changes.<br>
what's wrong with this?</p>

<p>Session duration is the delta between the timestamps of the first and the last interaction within a session (i.e. interactions with the same client id within a given timeframe). As far as I can tell your code will only create a single interaction per session, so there is no second data point to calculate a duration.</p>

python selenium selenium-webdriver google-analytics