Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Twine Google Analytics?

Hey all, new to Twine. Doing a project where I need to track people's choices to the narrative I'm making. Planning to use Google Analytics but haven't been able to figure out to how to best integrate it with Twine.

I have my GA tracking code in the story JavaScript (as recommended here) and then in a passage I have:
<script>ga('send', 'event', 'passage', 'loaded', 'ENDING');</script>

no errors, but nothing is showing up in my Analytics dashboard, but I know there is often a delay, so hopefully it'll show up in a few hours? Or am I doing something wrong?

I would like to track each Passage the user visits for simplicity on the analytics end. I think I could send the entire history of the player with an array or something at the end but then it'd be a little difficult to read the data on the GA dashboard. Seems easier to just send each passage but open to either option.

Should I use postrender? I'm just reading about this and it seems like I could set it to automatically send the analytics event at every passage render that way? And I should be able to grab the title with "this.title"? Is this the recommended solution? Are there any drawbacks?

Any advice appreciated. If the code I have does work (will know once GA dashboard updates) then I could just put it in every passage, but would love a more streamlined approach.
Sign In or Register to comment.