1

I have built a small visualisation and I want to allow third-party users to embed it within an iframe on their pages.

When they do this, I would like to use Analytics to track (i) how many people have seen the visualisation and (ii) the URLs on which it has been embedded.

The HTML and JS of my visualisation are both on the same domain, but obviously my domain is different from the domains on which it has been embedded.

I have read Google's documentation on iframes but it isn't helping me a great deal!

Two questions:

  1. Can I just use the basic Analytics setup in the normal way in my HTML, or are there any issues I need to be aware of?
  2. How do I pass in the parent URL as a custom dimension? Presumably I can't just get the URL of the parent page, for security reasons, so I'm wondering if I need to do something like this?
1

1 Answer 1

1

Be sure to use a custom tracker object for your Google Analytics script. The reason behind this is if a site is running Google Analytics, then their script calls might end up being recorded in your account as well!

So you cannot use the default GA script, but would rather use this Google Developer documentation on Creating Trackers.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.