Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add external link tracking to Fathom integration #534

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

KevinRohn
Copy link

This PR adds an option to track external link clicks in the Fathom integration. Regarding to the issue #450

When enabled, the integration tracks clicks on links leading to external domains. It sends an event to Fathom with the format "External link clicked: domain".

  • Modified index.ts to pass the new option to the script
  • Updated gitbook-manifest.yaml with the new configuration
  • Updated fathomScript.raw.js implement external link tracking
  • Small cosmetic variable change siteID renamed to siteId, this naming is also for other integrations

I hope I did anything correct, because I was not able to test it without the script injection scope.

Cheers,
Kevin

Copy link

changeset-bot bot commented Sep 4, 2024

⚠️ No Changeset found

Latest commit: 75033d8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@addisonschultz
Copy link
Contributor

Changes look good. But before I merge this, can you install and test this version to verify it works on your end too?

https://app.gitbook.com/integrations/test-fathom-update

If all is good, I can get this merged in, and deployed to the production version :)

@KevinRohn
Copy link
Author

Hey @addisonschultz , the tracking it self works, but I do not get a event for external site clicks. So it does not work yet.

@KevinRohn
Copy link
Author

Can I simply update this PR and it will reflect the changes in my space?

@addisonschultz
Copy link
Contributor

You can update this PR - and I'll update the integration after!

@KevinRohn
Copy link
Author

Hi @addisonschultz,

I made a mistake in the replace function call...
I fixed it with the last commit. See screenshot.
Screenshot 2024-09-13 at 17 07 20

Can you please update the integration?

@addisonschultz
Copy link
Contributor

It should be updated now - you can install with the same link! https://app.gitbook.com/test-fathom-update

@KevinRohn
Copy link
Author

@addisonschultz please update again.

@addisonschultz
Copy link
Contributor

Done ✅ The integration looks good - is it working as expected on your end as well?

@KevinRohn
Copy link
Author

Hi @addisonschultz,

now it works as expected!

Copy link
Contributor

@addisonschultz addisonschultz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you could make these changes, I'll be happy to merge and get this all live on the production version 😄

@@ -36,11 +36,27 @@ summary: |
categories:
- analytics
configurations:
space:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't use this space configuration key anymore - so you can omit this one from the configuration (See main right now, as it's been removed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

return new Response(script.replace('<TO_REPLACE>', siteId), {
const trackExternalLinks =
environment.siteInstallation?.configuration?.track_external_links ??
environment.spaceInstallation?.configuration?.track_external_links ??
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can omit environment.spaceInstallation... from here as well

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@KevinRohn
Copy link
Author

If you could make these changes, I'll be happy to merge and get this all live on the production version 😄

Sure, I will do this.

Please keep this PR open - I want to provide some changes to the event information.

window.fathom.trackEvent('External link clicked: ' + domainName);

The domainName info is not enough.

@KevinRohn
Copy link
Author

@addisonschultz ok, please update again for a final test

@addisonschultz
Copy link
Contributor

Sorry for the delay! It's just been updated again

@KevinRohn
Copy link
Author

KevinRohn commented Sep 18, 2024

Screenshot 2024-09-18 at 10 24 36

Can you please check the gitbook-manifest.yaml. After making the desired changes, I can no longer use the configuration page?

Edit:
Even If I "Go to site" and try to configure it under "Site integrations"

@addisonschultz
Copy link
Contributor

addisonschultz commented Sep 18, 2024

Looking into it 😕

@addisonschultz
Copy link
Contributor

@KevinRohn can you give it a try now? We should have fixed the bug causing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants