Google analytics

Riddles are running in iFrames on your website. This makes tracking events inside that Riddle iFrame a bit tricky. Especially for Google Analytics, which cannot be set up to track events on a domain like riddle.com, which does not belong to you. 

If you want to track page views or events from your embedded Riddle, you need to listen to events sent out by the Riddle iFrame and then trigger Google Analytics events accordingly.

Here are the key components needed for this:

a) a Riddle embedded on your own website

b) an empty iFrame added manually below the Riddle embed

c) JavaScript on the page where the Riddle is embedded

d) a PHP file hosted on your servers on a https:// secured domain

The iFrame

Add this iFrame code right below the Riddle embed. Make sure to keep the ID as is or if you need to change the ID, alter the JavaScript accordingly. The JavaScript below will load the external PHP file into this iFrame and pass it the necessary parameters that Google Analytics needs. 

JavaScript on Page

There are 2 variations of this script.

Variation 1:

This version only fires the Google Analytics tracking on the result page of your Riddle and is probably the preferred method. This way you do not count each and every Riddle slide as an individual page view. If you would rather trigger Analytics for every new Riddle page, use variation 2 please.

Variation 2:

This version fires Analytics every single time, the Riddle advances to a news slide


 

The external PHP File

Create a PHP file and name it google-analytics-iframe.php

If you want to give it a different name or place it in a directory outside of the directory where the page with your riddle is located, make sure to adjust the JavaScript line 10 accordingly


See full example here: https://examples.riddle.com/google-analytics.php