If your site uses AJAX to load content dynamically (e.g. infinite scroll, sliders, etc.), you'll need to take some additional steps. AJAX injects content changes into the parameters of the page, so you’ll need to update the data sent to the tracking code accordingly. This is done by updating _ain object with the new parameters. Once the parameters are changed, _ain.track() method should be called to register those changes and start tracking the page using modified data.

Example:

_ain.authors = "Jon Johnson, Tom Tomphson";
_ain.url = "http://www.example.com/news/articlename";
_ain.postid = "1234";
_ain.maincontent = "#main-content";
_ain.title = "Article title";
_ain.pubdate = "2015-03-10T13:04:50Z";
_ain.sections = "News, Politics";
_ain.tags = "news, politic, white house";
//call the track method
_ain.track();

Waiting for the content to be ready

By default, our tracking code starts to track the page from the moment it’s loaded. If you want to prevent this behavior, you can set parameter trackauto: false during _ain object initialization.

If trackauto is set to false, you should notify the tracking code when the data is ready. This is done by calling _ain.track() method.

Example:

var _ain = {
id: {DOMAIN_ID},
...
trackauto: false,
};

When content is loaded, you manually call _ain.track() method. This will most probably happen in some callback function provided by your AJAX script. Just make sure that you call _ain.track() when all content is loaded and all scripts are finished.

§

Dynamic maincontent parameter

When there is more than one article loaded, each article must have a unique CSS selector(s), so you have to make sure that there are no duplicate IDs or classes on the loaded content.

Example:
Each article has <div id="article"> tag which contains all of the content (ideal case). This means that static pages would have "#article" as a maincontent parameter. However, on dynamically loaded content, there will be more articles on the same page.

One solution is to add some kind of suffix to the id. This can be postid or some other string that makes an article unique.

For example, the first article would have #article-1, the second #article-2, and so on.

§

Implementing the code on the test/staging server first 

You may use the staging server for testing purposes but you're not required to do so.

We always start by registering a virtual domain in our system, e.g. test.yourdomain.com.

After we make sure that everything works well, we'll send you instructions on how to proceed further.

In most cases, we'll just send you new id value.

If your policy demands using a staging server when adding a new script, please whitelist our static IP address 109.92.139.218 so we can get access and test the script.

§

Still have a question? Feel free to drop us an email: support@contentinsights.com