If your visit is counted by Google Analytics implemented through javascript, then no, it won't work - file_get_contents()
doesn't run any javascript, just downloads the file. However, you could do it by sending page view through PHP: https://developers.google.com/analytics/devguides/collection/protocol/v1/devguide
Note that javascript gathers more information about the user than PHP can, so use with caution.
If your intention is to check whether the script was run, there are better and easier ways, such as logging any opening, or from specific IP, to your database or a text file.
Everything I suggested here presumes you can edit the opened file - your http://www.example.com/index.php
. If you need to trigger Google Analytics on a site you can't edit, you need something way more robust, like a web crawler or scraper, to execute the javascript. For inspiration: http://www.jacobward.co.uk/using-php-to-scrape-javascript-jquery-json-websites/