Tracking custom URLs and referrers using JavaScript

By default, Oracle Eloqua's asynchronous tracking scripts use the current request URL and referrer that the browser passes along to the Oracle Eloqua servers. This works well in the majority of cases, but there are times you may want to customize the URL and/or referrer being passed to Oracle Eloqua's servers to get more value from the system. One classic example is if you have a site that dynamically generates unique URLs that you want to only track as one resource for reporting purposes. To override the URL, simply call the elqTrackPageView function with a single parameter, the URL you want to track. For example:

<script type="text/javascript">
    var _elqQ = _elqQ || [];
    _elqQ.push(['elqSetSiteId', '123']);
    _elqQ.push(['elqTrackPageView', 'http://www.example.com/downloads/']);
	
    (function() {
        function async_load() {
            var s = document.createElement('script');
            s.type = 'text/javascript';
            s.async = true;
            s.src = '//img.en25.com/i/elqCfg.min.js';
            var x = document.getElementsByTagName('script')[0];
            x.parentNode.insertBefore(s, x);
        }
        if (window.addEventListener) window.addEventListener('DOMContentLoaded', async_load, false);
        else if (window.attachEvent) window.attachEvent('onload', async_load);
    })();
</script>

If you would also like to override the referrer as well, adding a second parameter to elqTrackPageView() allows you to do this:

<script type="text/javascript">
    var _elqQ = _elqQ || [];
    _elqQ.push(['elqSetSiteId', '123']);
    _elqQ.push(['elqTrackPageView', 'http://www.example.com/downloads/', 'http://www.example.com']);
	
    (function() {
        function async_load() {
            var s = document.createElement('script');
            s.type = 'text/javascript';
            s.async = true;
            s.src = '//img.en25.com/i/elqCfg.min.js';
            var x = document.getElementsByTagName('script')[0];
            x.parentNode.insertBefore(s, x);
        }
        if (window.addEventListener) window.addEventListener('DOMContentLoaded', async_load, false);
        else if (window.attachEvent) window.attachEvent('onload', async_load);
    })();
</script>

Learn more

Oracle Eloqua asynchronous tracking scripts